aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quicktemplates2/qquicktumbler.cpp5
-rw-r--r--tests/auto/controls/data/tst_tumbler.qml21
2 files changed, 24 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquicktumbler.cpp b/src/quicktemplates2/qquicktumbler.cpp
index e8fbcbd5..5f17cd29 100644
--- a/src/quicktemplates2/qquicktumbler.cpp
+++ b/src/quicktemplates2/qquicktumbler.cpp
@@ -667,8 +667,9 @@ void QQuickTumblerPrivate::syncCurrentIndex()
return;
}
- // PathView likes to use 0 as currentIndex for empty models, but we use -1 for that.
- if (q->count() == 0 && actualViewIndex == 0)
+ // actualViewIndex might be 0 or -1 for PathView and ListView respectively,
+ // but we always use -1 for that.
+ if (q->count() == 0 && actualViewIndex <= 0)
return;
ignoreCurrentIndexChanges = true;
diff --git a/tests/auto/controls/data/tst_tumbler.qml b/tests/auto/controls/data/tst_tumbler.qml
index c103aefc..3a09bd9f 100644
--- a/tests/auto/controls/data/tst_tumbler.qml
+++ b/tests/auto/controls/data/tst_tumbler.qml
@@ -1257,4 +1257,25 @@ TestCase {
tumbler.height *= 1.4
tryCompare(delegate, "displacement", 0)
}
+
+ //QTBUG-84426
+ Component {
+ id: initialCurrentIndexTumbler
+
+ Tumbler {
+ anchors.centerIn: parent
+ width: 60
+ height: 200
+ delegate: Text {text: modelData}
+ model: 10
+ currentIndex: 4
+ }
+ }
+
+ function test_initialCurrentIndex() {
+ var tumbler = createTemporaryObject(initialCurrentIndexTumbler, testCase, {wrap: true});
+ compare(tumbler.currentIndex, 4);
+ tumbler = createTemporaryObject(initialCurrentIndexTumbler, testCase, {wrap: false});
+ compare(tumbler.currentIndex, 4);
+ }
}