aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJan Arve Sæther <jan-arve.saether@qt.io>2023-04-19 16:39:20 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-04-26 13:38:41 +0000
commit466e17a9ae44040876c7fcd29870ec57c3ffbb43 (patch)
tree8aa61143f578fff842f2a7f4f74236f11d23ea46 /tests
parent680ddb8b4e0c40b0c9e9fe90dc17085cd63b3117 (diff)
Fix StackLayout to keep the current visible item after insert/removal
If an item is inserted or deleted at an index less than or equal to the current index, StackLayout.currentIndex will be updated in order to reflect which is the current visible item. This is consistent with QStackedLayout, QStackedWidget and TabBar [ChangeLog][QtQuick][Layouts] StackLayout will now update currentIndex if an Item is inserted or removed at an index less than or equal to the current index. Task-number: QTBUG-112691 Change-Id: Id1d687e309c8f199a4f68698b53ca7c169f17dcd Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit adc3d8b2e40ca2853b4baf5ea893021a799c21f4) 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.qml5
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml b/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml
index e6200a3e23..ad5cafaddb 100644
--- a/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml
+++ b/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml
@@ -828,7 +828,7 @@ Item {
verifyVisibilityOfItems()
model.insert(0, { "color": "black" })
- compare(layout.currentIndex, 0)
+ compare(layout.currentIndex, 1)
compare(layout.count, 4)
verifyVisibilityOfItems()
@@ -855,10 +855,11 @@ Item {
verifyVisibilityOfItems()
model.insert(1, { "color": "brown" })
- compare(layout.currentIndex, 1)
+ compare(layout.currentIndex, 2)
compare(layout.count, 3)
verifyVisibilityOfItems()
+ // remove red, currentIndex should decrease
model.remove(0, 1)
compare(layout.currentIndex, 1)
compare(layout.count, 2)