diff options
author | Jan Arve Saether <jan-arve.saether@digia.com> | 2014-01-15 13:22:12 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-28 12:13:52 +0100 |
commit | 17788ca8f0d6fe4fb0d03e99e34ed667fde54379 (patch) | |
tree | a10790a239ff94cca7d2df096bbdb9c18f2a8d29 | |
parent | 5dc805c86077ee9cd10af530f802fdda879cfb6a (diff) | |
download | qtquickcontrols-17788ca8f0d6fe4fb0d03e99e34ed667fde54379.tar.gz qtquickcontrols-17788ca8f0d6fe4fb0d03e99e34ed667fde54379.tar.bz2 qtquickcontrols-17788ca8f0d6fe4fb0d03e99e34ed667fde54379.zip |
Allow size hint changes during a rearrange.
Previously, we marked the layout as not dirty straight after a
rearrange was done. However, in the case of when a size hint changed
during a rearrange that would block the pending rearrange (since it
only perform the actual rearrange if its dirty).
Instead, mark the layout as not dirty *before* the rearrange.
This will allow bindings such as
implicitWidth: height
to execute the pending rearrange.
(Although such bindings are not encouraged)
Task-number: QTBUG-36169
Change-Id: I75bd821a0ca4302026bd5dac01287ca3359d471b
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
-rw-r--r-- | src/layouts/qquicklinearlayout.cpp | 4 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_rowlayout.qml | 36 |
2 files changed, 39 insertions, 1 deletions
diff --git a/src/layouts/qquicklinearlayout.cpp b/src/layouts/qquicklinearlayout.cpp index 554ce10c..c15f2ed4 100644 --- a/src/layouts/qquicklinearlayout.cpp +++ b/src/layouts/qquicklinearlayout.cpp @@ -499,9 +499,11 @@ void QQuickGridLayoutBase::rearrange(const QSizeF &size) qSwap(left, right); */ + // Set m_dirty to false in case size hint changes during arrangement. + // This could happen if there is a binding like implicitWidth: height + QQuickLayout::rearrange(size); d->engine.setGeometries(QRectF(QPointF(0,0), size)); - QQuickLayout::rearrange(size); } bool QQuickGridLayoutBase::shouldIgnoreItem(QQuickItem *child, QQuickLayoutAttached *&info, QSizeF *sizeHints) diff --git a/tests/auto/controls/data/tst_rowlayout.qml b/tests/auto/controls/data/tst_rowlayout.qml index c82a16d4..9db6c803 100644 --- a/tests/auto/controls/data/tst_rowlayout.qml +++ b/tests/auto/controls/data/tst_rowlayout.qml @@ -536,6 +536,42 @@ Item { layout.destroy() } + + Component { + id: layout_change_implicitWidth_during_rearrange + ColumnLayout { + width: 100 + height: 20 + RowLayout { + spacing: 0 + Rectangle { + Layout.fillHeight: true + Layout.fillWidth: false + implicitWidth: height + color: "red" + } + Rectangle { + Layout.fillHeight: true + Layout.fillWidth: true + color: "blue" + } + } + } + } + + function test_change_implicitWidth_during_rearrange() { + var layout = layout_change_implicitWidth_during_rearrange.createObject(container) + var red = layout.children[0].children[0] + var blue = layout.children[0].children[1] + waitForRendering(layout); + tryCompare(red, 'width', 20) + tryCompare(blue, 'width', 80) + layout.height = 40 + tryCompare(red, 'width', 40) + tryCompare(blue, 'width', 60) + layout.destroy() + } + Component { id: layout_addIgnoredItem_Component RowLayout { |