diff options
author | Jan Arve Saether <jan-arve.saether@theqtcompany.com> | 2014-10-20 15:40:18 +0200 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@theqtcompany.com> | 2014-10-31 08:07:08 +0100 |
commit | e93db692f88ad788a89a229ca974d5598dc104c2 (patch) | |
tree | 079e2bae035dee298609065d8e512dba44f807f8 /tests/auto/qgraphicslinearlayout | |
parent | 809119d7a42ebfa5dec9c842e510e569e385513a (diff) |
Adjust the layout if a QGraphicsWidget is explicitly hidden
Task-number: QTBUG-20132
Change-Id: Iab59fc9b61d4ca1bb2208c479a027da6eb0283a9
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
(cherry picked from qtbase/bf200fc948d89e1a735a8bcca879654028f944d2)
Diffstat (limited to 'tests/auto/qgraphicslinearlayout')
-rw-r--r-- | tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index dd5b9d0ab6..ab20bfc166 100644 --- a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -108,6 +108,7 @@ private slots: void testOffByOneInLargerLayout(); void testDefaultAlignment(); void combineSizePolicies(); + void hiddenItems(); // Task specific tests void task218400_insertStretchCrash(); @@ -1649,6 +1650,33 @@ void tst_QGraphicsLinearLayout::combineSizePolicies() QCOMPARE(layout->maximumHeight(), qreal(200)); } +void tst_QGraphicsLinearLayout::hiddenItems() +{ + QGraphicsWidget *widget = new QGraphicsWidget; + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal, widget); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(2); + + RectWidget *w1 = new RectWidget; + w1->setPreferredSize(QSizeF(20, 20)); + layout->addItem(w1); + + RectWidget *w2 = new RectWidget; + w2->setPreferredSize(QSizeF(20, 20)); + layout->addItem(w2); + + RectWidget *w3 = new RectWidget; + w3->setPreferredSize(QSizeF(20, 20)); + layout->addItem(w3); + + QCOMPARE(layout->preferredWidth(), qreal(64)); + w2->hide(); + QCOMPARE(layout->preferredWidth(), qreal(42)); + w2->show(); + QCOMPARE(layout->preferredWidth(), qreal(64)); +} + + QTEST_MAIN(tst_QGraphicsLinearLayout) #include "tst_qgraphicslinearlayout.moc" |