diff --git a/src/layouts/qquickgridlayoutengine_p.h b/src/layouts/qquickgridlayoutengine_p.h index 29317ffbbb8d89c63c9c6196b324bcb70d14dbe9..8842d36a77a2fdd0e9f444fbcce728e22538d2ab 100644 --- a/src/layouts/qquickgridlayoutengine_p.h +++ b/src/layouts/qquickgridlayoutengine_p.h @@ -112,8 +112,16 @@ public: void setGeometry(const QRectF &rect) { const QRect r(rect.toRect()); + const QSize newSize(r.size()); m_item->setPosition(r.topLeft()); - m_item->setSize(r.size()); + QSizeF oldSize(m_item->width(), m_item->height()); + if (newSize == oldSize) { + if (QQuickLayout *lay = qobject_cast<QQuickLayout *>(m_item)) + if (lay->arrangementIsDirty()) + lay->rearrange(newSize); + } else { + m_item->setSize(newSize); + } } QQuickItem *layoutItem() const { return m_item; } diff --git a/src/layouts/qquicklayout_p.h b/src/layouts/qquicklayout_p.h index 0239739a649e90c5b17f963b5f61169bc11a0d18..76c197173b84d311aa0d70ce111cc5c0e36272d4 100644 --- a/src/layouts/qquicklayout_p.h +++ b/src/layouts/qquicklayout_p.h @@ -77,9 +77,10 @@ public: void componentComplete(); virtual QSizeF sizeHint(Qt::SizeHint whichSizeHint) const = 0; virtual void invalidate(QQuickItem * childItem = 0); + virtual void rearrange(const QSizeF &); + bool arrangementIsDirty() const { return m_dirty; } protected: bool event(QEvent *e); - virtual void rearrange(const QSizeF &); enum Orientation { Vertical = 0, diff --git a/tests/auto/controls/data/tst_rowlayout.qml b/tests/auto/controls/data/tst_rowlayout.qml index e92dad47efec3eee7d36588386034eb4a1c7ab95..d04419f0fa92bc9cac723d318d3cd8ed38ac124a 100644 --- a/tests/auto/controls/data/tst_rowlayout.qml +++ b/tests/auto/controls/data/tst_rowlayout.qml @@ -658,5 +658,50 @@ Item { layout.visible = false layout.destroy() // Do not crash } + + + Component { + id: rearrangeNestedLayouts_Component + RowLayout { + id: layout + anchors.fill: parent + width: 200 + height: 20 + RowLayout { + id: row + spacing: 0 + + Rectangle { + id: fixed + color: 'red' + implicitWidth: 20 + implicitHeight: 20 + } + Rectangle { + id: filler + color: 'grey' + Layout.fillWidth: true + implicitHeight: 20 + } + } + } + } + + function test_rearrangeNestedLayouts() + { + var layout = rearrangeNestedLayouts_Component.createObject(container) + var fixed = layout.children[0].children[0] + var filler = layout.children[0].children[1] + + compare(itemRect(fixed), [0,0,20,20]) + compare(itemRect(filler), [20,0,180,20]) + + fixed.implicitWidth = 100 + wait(20); // wait for at least 20 ms (this matches the time between two frame + // repaints for 50hz displays) + compare(itemRect(fixed), [0,0,100,20]) + compare(itemRect(filler), [100,0,100,20]) + + } } }