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

QTabWidget::sizeHint() adds height of tab bar, even if the tab bar is hidden

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.11.0
    • 5.6.2, 5.9.2
    • None
    • Windows 10
    • b64f3f6ca97e299176ca8990402650552a90f704

    Description

      When a QTabWidget's tab bar is hidden (either manually or with QTabWidget::setTabBarAutoHide()), QTabWidget::sizeHint() still adds the bar's height to its result. This leads to unexpected behaviour when putting the QTabWidget inside e.g. a QScrollArea: when resizing the scroll area, the vertical scroll bar is shown before the contained widget has reached its expected minimum size.

      The attached sample program creates two windows, both with a QScrollArea, containing a QTabWidget. One tab widget only has one tab (hidden due to QTabWidget::setTabBarAutoHide(true)), another with two tabs. Each tab is a green, fixed height widget on top of a red, expandable widget with zero minimum height.

      Here, the scroll areas are large enough to not need a scroll bar:

      Reducing the height slightly, both widgets show a vertical scroll bar:

      On the right, I would have expected the red widget to be resized to fit inside the smaller window, so no vertical scroll bar would be necessary.

      Attachments

        1. main.cpp
          2 kB
        2. tabwidget_issue_1.png
          tabwidget_issue_1.png
          28 kB
        3. tabwidget_issue_2.png
          tabwidget_issue_2.png
          22 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            chehrlic Christian Ehrlicher
            bkloster Benjamin Kloster
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes