aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJan Arve Sæther <jan-arve.saether@qt.io>2022-08-24 15:41:29 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-08-26 15:47:01 +0000
commit0fa73f20da54029c1eb9729c8df6730d1a02c008 (patch)
treee7663214b78a38014a3c0f07867715e532aa7a05 /tests
parent1aebfa3e036df1a3aa6ab697a93f9a335e383b70 (diff)
StackLayout: Do not set size of children to (-1, -1)
The item-size-hint-cache in StackLayout was not always valid when QQuickStackLayout::rearrange() was entered, so it would end up setting the size of the item to (-1, -1) Fixes: QTBUG-105899 Change-Id: I632aa18bb10b84d59af35cd3c7cb0c675d8d1692 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io> (cherry picked from commit 9a4874ab7f18a54b2497f689dfd7f7a2ee0516b8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml b/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml
index a04e7a9dd7..3455dd5cc1 100644
--- a/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml
+++ b/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml
@@ -263,5 +263,56 @@ Item {
compare(layout.implicitWidth, 20)
compare(layout.implicitHeight, 20)
}
+
+ Component {
+ id: layout_setCurrentIndex_Component
+
+ StackLayout {
+ width: 200
+ height: 200
+
+ property alias firstItem : rect
+ property alias secondItem: rowLayout
+
+ Rectangle {
+ id: rect
+ color: "red"
+ implicitWidth: 10
+ implicitHeight: 10
+ }
+ RowLayout {
+ id: rowLayout
+ spacing: 0
+ Rectangle {
+ color: "green"
+ implicitWidth: 10
+ implicitHeight: 10
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+ Rectangle {
+ color: "blue"
+ implicitWidth: 10
+ implicitHeight: 10
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+ }
+ }
+ }
+
+ function test_setCurrentIndex()
+ {
+ var layout = layout_setCurrentIndex_Component.createObject(container)
+ compare(layout.firstItem.width, 200)
+
+ // Invalidate the StackLayout (and its cached size hints)
+ layout.firstItem.implicitWidth = 42
+
+ layout.currentIndex = 1
+ compare(layout.secondItem.width, 200) // width should not be -1
+ layout.destroy()
+ }
+
}
}