diff options
author | Eduardo M. Fleury <eduardo.fleury@openbossa.org> | 2009-11-25 16:27:36 (GMT) |
---|---|---|
committer | Eduardo M. Fleury <eduardo.fleury@openbossa.org> | 2009-11-27 18:50:56 (GMT) |
commit | 2ef40cee608ddc57a5bfc4ceb91c149b526fe53a (patch) | |
tree | c77c8c0ac0834f0b1c8f223163df284fd98621ed /tests/auto/qgraphicsanchorlayout | |
parent | 41f1276392444b9e46b30f3537a8a63af6fffc9d (diff) | |
download | Qt-2ef40cee608ddc57a5bfc4ceb91c149b526fe53a.zip Qt-2ef40cee608ddc57a5bfc4ceb91c149b526fe53a.tar.gz Qt-2ef40cee608ddc57a5bfc4ceb91c149b526fe53a.tar.bz2 |
QGAL: default spacing can be unset using a negative value
After a default spacing is set through QGAL::setSpacing() family
of methods, the user must be able to unset it.
To avoid adding another public method, we enabled this feature
by allowing a negative value to be passed to those methods.
Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
Reviewed-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>
Diffstat (limited to 'tests/auto/qgraphicsanchorlayout')
-rw-r--r-- | tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index e2f87b8..aa67ac5 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -88,6 +88,7 @@ private slots: void spacingPersistency(); void snakeParallelWithLayout(); void parallelToHalfLayout(); + void globalSpacing(); }; class RectWidget : public QGraphicsWidget @@ -1976,5 +1977,45 @@ void tst_QGraphicsAnchorLayout::parallelToHalfLayout() QCOMPARE(maximumSizeHint, QSizeF(400, 100) + overhead); } +void tst_QGraphicsAnchorLayout::globalSpacing() +{ + QGraphicsWidget *a = createItem(); + QGraphicsWidget *b = createItem(); + + QGraphicsWidget w; + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout(&w); + + l->addCornerAnchors(l, Qt::TopLeftCorner, a, Qt::TopLeftCorner); + l->addCornerAnchors(a, Qt::BottomRightCorner, b, Qt::TopLeftCorner); + l->addCornerAnchors(b, Qt::BottomRightCorner, l, Qt::BottomRightCorner); + + w.resize(w.effectiveSizeHint(Qt::PreferredSize)); + qreal vSpacing = b->geometry().top() - a->geometry().bottom(); + qreal hSpacing = b->geometry().left() - a->geometry().right(); + + // Set spacings manually + l->setVerticalSpacing(vSpacing + 10); + l->setHorizontalSpacing(hSpacing + 5); + + w.resize(w.effectiveSizeHint(Qt::PreferredSize)); + qreal newVSpacing = b->geometry().top() - a->geometry().bottom(); + qreal newHSpacing = b->geometry().left() - a->geometry().right(); + + QCOMPARE(newVSpacing, vSpacing + 10); + QCOMPARE(newHSpacing, hSpacing + 5); + + // Set a negative spacing. This will unset the previous spacing and + // bring back the widget-defined spacing. + l->setSpacing(-1); + + w.resize(w.effectiveSizeHint(Qt::PreferredSize)); + newVSpacing = b->geometry().top() - a->geometry().bottom(); + newHSpacing = b->geometry().left() - a->geometry().right(); + + QCOMPARE(newVSpacing, vSpacing); + QCOMPARE(newHSpacing, hSpacing); +} + + QTEST_MAIN(tst_QGraphicsAnchorLayout) #include "tst_qgraphicsanchorlayout.moc" |