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

May be incorrect QAbstractScrollArea::sizeHint() behavior.

    XMLWordPrintable

Details

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

    Description

      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?

      Attachments

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

        Activity

          People

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

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes