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

QScrollArea does not respect the children's sizeHint() after the initial show().

    XMLWordPrintable

Details

    Description

      When having a QScrollArea with a child widget that the user can add or remove widgets from, then the scroll area's size is not updated accordingly because it caches the sizeHint() from the first time the scroll area was shown. So, if the scroll area's sizeHint() is reimplemented to increment its size when the size increases, then the scrollarea will only show scrollbars instead of resizing if its size is increased after it was shown .

      The layout code uses a private class called QWidgetItemV2 which performs caching of QLayoutItem sizes. The problem with this class appears to be that there is no way to invalidate the cached values after the first time they are calculated, so sizeHint() never gets called again for any of the child widgets or layouts.

      invalidate() (actually setDirty()) for all of the QLayout-derived classes should correctly re-set the Dirty cache flags for all QLayoutItems so that their sizeHint()s will be re-evaluated whenever the layout is invalidate()ed.

      The attached example demonstrates the problem.

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            naevdal Sigrid Fjell Nævdal (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes