diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-02-17 20:46:33 +0100 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-03-07 18:36:06 +0000 |
commit | b64f3f6ca97e299176ca8990402650552a90f704 (patch) | |
tree | 5018cbe1bf3f76e07772bd16268ed5b0ac8a179e /tests/auto/widgets/widgets/qtabwidget | |
parent | 3185b40d5de1092ed2bdd83f72478a344c5fc9e9 (diff) |
QTabWidget: Do not add tabbar size during sizeHint() when it is hidden
Since Qt 5.4 the QTabBar can be automatically hidden when it has less
then 2 tabs. Therefore the sizeHint should not consider the tabbars
size when the tabbar is hidden.
Task-number: QTBUG-64715
Change-Id: I2f248f88d9070de5354f7344c7628a78442ab499
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/auto/widgets/widgets/qtabwidget')
-rw-r--r-- | tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp index 2a2331c3bf..b5ffb90e42 100644 --- a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp +++ b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp @@ -98,6 +98,7 @@ private slots: void heightForWidth(); void tabBarClicked(); void moveCurrentTab(); + void autoHide(); private: int addPage(); @@ -713,5 +714,33 @@ void tst_QTabWidget::moveCurrentTab() QCOMPARE(tabWidget.currentWidget(), secondTab); } +void tst_QTabWidget::autoHide() +{ + QTabWidget tabWidget; + QWidget* firstTab = new QWidget(&tabWidget); + tabWidget.addTab(firstTab, "0"); + const auto sizeHint1 = tabWidget.sizeHint(); + const auto minSizeHint1 = tabWidget.minimumSizeHint(); + const auto heightForWidth1 = tabWidget.heightForWidth(20); + + QWidget* secondTab = new QWidget(&tabWidget); + tabWidget.addTab(secondTab, "1"); + const auto sizeHint2 = tabWidget.sizeHint(); + const auto minSizeHint2 = tabWidget.minimumSizeHint(); + const auto heightForWidth2 = tabWidget.heightForWidth(20); + + tabWidget.setTabBarAutoHide(true); + // size should not change + QCOMPARE(sizeHint2, tabWidget.sizeHint()); + QCOMPARE(minSizeHint2, tabWidget.minimumSizeHint()); + QCOMPARE(heightForWidth2, tabWidget.heightForWidth(20)); + + tabWidget.removeTab(1); + // this size should change now since the tab should be hidden + QVERIFY(sizeHint1.height() > tabWidget.sizeHint().height()); + QVERIFY(minSizeHint1.height() > tabWidget.sizeHint().height()); + QVERIFY(heightForWidth1 > tabWidget.heightForWidth(20)); +} + QTEST_MAIN(tst_QTabWidget) #include "tst_qtabwidget.moc" |