From cf366e8b862a616efd7c3d4683d59971f795d476 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Fri, 24 May 2013 17:55:21 +0200 Subject: Made sure items with preferred width of 0 could also stretch If no stretch factors were specified, we used the preferred size as a stretch factor. Obviously, that didn't work if the preferred size was actually 0. This patch works around this by actually setting the stretch factor to 1.0 if this is the case. This should work fine in most cases, except for the case where there are also other items with a preferred size close to 0. In this case, the item with preferred size 0 will just grow faster than an item with e.g. preferred size 0.1. Task-number: QTBUG-31217 Change-Id: I966455da0bdd00308591c7f7cfbc4e134d423e57 Reviewed-by: Paul Olav Tvete --- .../qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp') diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index 41e5ed466c..8c8f27d635 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -1884,6 +1884,18 @@ void tst_QGraphicsGridLayout::defaultStretchFactors_data() << QSizeF(10,10) << QSizeF(10,10) << QSizeF(10,10) ); + QTest::newRow("preferredsizeIsZero") << (ItemList() + << ItemDesc(0,0) + .preferredSizeHint(QSizeF(0,10)) + << ItemDesc(0,1) + .preferredSizeHint(QSizeF(10,10)) + .maxSize(QSizeF(20, 10)) + ) + << QSizeF(30, 10) + << (SizeList() + << QSizeF(10,10) << QSizeF(20,10) + ); + QTest::newRow("ignoreitem01") << (ItemList() << ItemDesc(0,0) .preferredSizeHint(QSizeF(10,10)) -- cgit v1.2.3