summaryrefslogtreecommitdiff
path: root/tests/auto
diff options
context:
space:
mode:
authorJan Arve Saether <jan-arve.saether@digia.com>2013-03-13 08:58:54 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-14 16:25:44 +0100
commit0c935730b2cdf459567cf4c85872ca93ad31fa62 (patch)
tree0e628f35bc5ded12e8afdc819e9c7cb34f78f7d1 /tests/auto
parent5145aec470344b43669a6e1e68ccade3886d5351 (diff)
downloadqtquickcontrols-0c935730b2cdf459567cf4c85872ca93ad31fa62.tar.gz
Rearrange only the topmost layout.
Since we also rearrange in geometryChanged(), this should ensure that we recurse down and arrange all sublayouts. This assumes that objects are constructed in bottom-up order. (That's what componentComplete() indicates.) Previously we would risk rearranging sublayouts several times: 1. Sublayout got componentComplete -> geometryChanged -> rearrange() 2. Parent layout got componentComplete -> geometryChanged -> rearrange() 3. Since the sublayout was a layout item of the parent layout it could get a geometry change again, causing it to rearrange again. This also fixes the issue where the implicitWidth/Height of the layout was not immediately set after componentComplete, which could cause it to get the wrong initial size. Change-Id: I63a35dd934cd3ace01fab6319333d531631a6f4e Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/controls/data/tst_rowlayout.qml70
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_rowlayout.qml b/tests/auto/controls/data/tst_rowlayout.qml
index e444dd95..af2f14e6 100644
--- a/tests/auto/controls/data/tst_rowlayout.qml
+++ b/tests/auto/controls/data/tst_rowlayout.qml
@@ -123,5 +123,75 @@ Item {
compare(tmp.r1.width, 10);
compare(tmp.r2.width, 20);
}
+
+ function test_initialNestedLayouts() {
+ var test_layoutStr =
+ 'import QtQuick 2.0; \
+ import QtQuick.Layouts 1.0; \
+ ColumnLayout { \
+ id : col; \
+ property alias row: _row; \
+ objectName: "col"; \
+ anchors.fill: parent; \
+ RowLayout { \
+ id : _row; \
+ property alias r1: _r1; \
+ property alias r2: _r2; \
+ objectName: "row"; \
+ spacing: 0; \
+ Rectangle { \
+ id: _r1; \
+ color: "red"; \
+ implicitWidth: 50; \
+ implicitHeight: 20; \
+ } \
+ Rectangle { \
+ id: _r2; \
+ color: "green"; \
+ implicitWidth: 50; \
+ implicitHeight: 20; \
+ Layout.horizontalSizePolicy: Layout.Expanding; \
+ } \
+ } \
+ } '
+ var col = Qt.createQmlObject(test_layoutStr, container, '');
+ tryCompare(col, 'width', 200);
+ tryCompare(col.row, 'width', 200);
+ tryCompare(col.row.r1, 'width', 50);
+ tryCompare(col.row.r2, 'width', 150);
+ }
+
+ function test_implicitSize() {
+ var test_layoutStr =
+ 'import QtQuick 2.0; \
+ import QtQuick.Layouts 1.0; \
+ RowLayout { \
+ id: row; \
+ objectName: "row"; \
+ spacing: 0; \
+ height: 30; \
+ anchors.left: parent.left; \
+ anchors.right: parent.right; \
+ Rectangle { \
+ color: "red"; \
+ height: 2; \
+ Layout.minimumWidth: 50; \
+ } \
+ Rectangle { \
+ color: "green"; \
+ width: 10; \
+ Layout.minimumHeight: 4; \
+ } \
+ Rectangle { \
+ implicitWidth: 1000; \
+ Layout.maximumWidth: 40; \
+ implicitHeight: 6 \
+ } \
+ } '
+ var row = Qt.createQmlObject(test_layoutStr, container, '');
+ compare(row.implicitWidth, 50 + 10 + 40);
+ compare(row.implicitHeight, 6);
+
+ }
}
}