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

Wrong sizeHint for QTreeWidget having an AdjustToContents sizeAndAdjustPolicy

    XMLWordPrintable

Details

    • macOS, Windows
    • 8c18a245b (dev), 0c9787bab (6.6), c26e7f278 (6.5)

    Description

      When building the attached Qt Creator project, I get following output in Qt 5.12:

      While I get following output in Qt 6.5:

      The left widget is a QTreeWidget having AdjustToContents as sizeAndAdjustPolicy.
      The QTreeWidget is placed in a QHBoxLayout next to a QLineEdit. As the QLineEdit has a bigger stretch factor, we would expect a result as in Qt 5.12.
      When starting the Qt 6.5 application, you can see the QTreeWidget grows from the 'normal' size (aka the size in Qt 5.12) until no place is left in the main widget. (see attached video)

      I looked around in the Qt code and came across this change: https://codereview.qt-project.org/c/qt/qtbase/+/235582
      It changes the location where the size of the scrollbar is taken into account which is fine. But it also changes the way to check the scrollbar visibility. Before it was using the isVisible() call, while now it is done using the isHidden() call.
      However the scrollbar itself is never hidden/made visible, but the wrapper around it (aka the QAbstractScrollAreaScrollBarContainer).

      When changing the visibility check for the scrollBars in QAbstractScrollArea::sizeHint() from d->vbar->isHidden() to d->scrollBarContainers[Qt::Vertical]->isHidden() it works correct again. (of course the same should be done for the horizontal scrollbar)

      Attachments

        1. Qt 5.12.6.png
          Qt 5.12.6.png
          28 kB
        2. Qt 6.5.0.mov
          11 kB
        3. Qt 6.5.0.png
          Qt 6.5.0.png
          27 kB
        4. TreeWidget.zip
          2 kB

        Issue Links

          For Gerrit Dashboard: QTBUG-113552
          # Subject Branch Project Status CR V

          Activity

            People

              vhilshei Volker Hilsheimer
              dbutijn David Butijn
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes