From 8a43ccdaf3bbd1e77045cbb63231e201ea23896f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Fri, 10 Sep 2010 13:25:41 +0200 Subject: Fix a regression where setPreferredSize(QSize(100, -1)) did not work. Regressed by change 515991426832a6333f2fd9e639bd4c83e2b27cef Reviewed-by: Frederik Gladhorn --- src/gui/graphicsview/qgraphicslayoutitem.cpp | 2 +- tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicslayoutitem.cpp b/src/gui/graphicsview/qgraphicslayoutitem.cpp index 3707591..634f68c 100644 --- a/src/gui/graphicsview/qgraphicslayoutitem.cpp +++ b/src/gui/graphicsview/qgraphicslayoutitem.cpp @@ -234,7 +234,7 @@ void QGraphicsLayoutItemPrivate::setSize(Qt::SizeHint which, const QSizeF &size) if (userSizeHints) { if (size == userSizeHints[which]) return; - } else if (!size.isValid()) { + } else if (size.width() < 0 && size.height() < 0) { return; } diff --git a/tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp b/tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp index 879e12b..dbffa6e 100644 --- a/tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp +++ b/tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp @@ -75,6 +75,7 @@ private slots: void setPreferredSize_data(); void setPreferredSize(); void setSizePolicy_data(); + void setPreferredSize2(); void setSizePolicy(); }; @@ -343,6 +344,13 @@ void tst_QGraphicsLayoutItem::setPreferredSize() } } +void tst_QGraphicsLayoutItem::setPreferredSize2() +{ + SubQGraphicsLayoutItem layoutItem; + layoutItem.setPreferredSize(QSizeF(30, -1)); + QCOMPARE(layoutItem.preferredWidth(), qreal(30)); +} + void tst_QGraphicsLayoutItem::setSizePolicy_data() { QTest::addColumn("policy"); -- cgit v0.12