Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-81223

May be incorrect QAbstractScrollArea::sizeHint() behavior.

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Unresolved
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.14.0
    • Widgets: Itemviews
    • None
    • All

      Compile and run sample.cpp attached.

      You will see main window with tableview inside. The tableview has small empty space just right of horizontal header. This is due to QAbstractScrollArea::sizeHint() implementation that takes into account virtual vertical scrollbar that can appear instead of that space.

      The code is copy/pasted fragment of current implementation in Qt 5.14.0:

      QSize QAbstractScrollArea::sizeHint() const
      {
      Q_D(const QAbstractScrollArea);
      if (d->sizeAdjustPolicy == QAbstractScrollArea::AdjustIgnored)
      return QSize(256, 192);

      if (!d->sizeHint.isValid() || d->sizeAdjustPolicy == QAbstractScrollArea::AdjustToContents)

      { const int f = 2 * d->frameWidth; const QSize frame( f, f ); const bool vbarHidden = d->vbar->isHidden() || d->vbarpolicy == Qt::ScrollBarAlwaysOff; const bool hbarHidden = d->hbar->isHidden() || d->hbarpolicy == Qt::ScrollBarAlwaysOff; const QSize scrollbars(vbarHidden ? 0 : d->vbar->sizeHint().width(), hbarHidden ? 0 : d->hbar->sizeHint().height()); d->sizeHint = frame + scrollbars + viewportSizeHint(); }

      return d->sizeHint;
      }

       

      Is this correct? Uncomment function CTableView::sizeHint() in attached sample.cpp, recompile and run again. You will see that empty space disappeared. Which behavior is more relevant?

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            cooler Cooler
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes