diff options
| author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2025-10-12 23:00:20 +0300 |
|---|---|---|
| committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2025-10-12 23:00:20 +0300 |
| commit | 4826f86e274f1b29bd769e6790824f9e62a40f62 (patch) | |
| tree | c2cc4bb09ca91951a2641e33c3b0a65deb0af877 /src/quickcontrolsimpl/qquicktumblerview.cpp | |
| parent | 0f0972d542d9869c2dcfaf9c963d42ff32766460 (diff) | |
| parent | 844f9b9b376838bcb44324984876f8bf99d85d38 (diff) | |
Merge tag 'v6.5.7-lts-lgpl' into 6.56.5
Qt 6.5.7-lts-lgpl release
Diffstat (limited to 'src/quickcontrolsimpl/qquicktumblerview.cpp')
| -rw-r--r-- | src/quickcontrolsimpl/qquicktumblerview.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/quickcontrolsimpl/qquicktumblerview.cpp b/src/quickcontrolsimpl/qquicktumblerview.cpp index 785791d117..a9606c6c20 100644 --- a/src/quickcontrolsimpl/qquicktumblerview.cpp +++ b/src/quickcontrolsimpl/qquicktumblerview.cpp @@ -159,9 +159,25 @@ void QQuickTumblerView::createView() // the view animates any potential currentIndex change over one second, // which we don't want when the contentItem has just been created. m_listView->setDelegate(m_delegate); + + QQuickTumblerPrivate *tumblerPrivate = QQuickTumblerPrivate::get(m_tumbler); + // Ignore currentIndex change: + // If the view's currentIndex is changed by setHighlightRangeMode(), + // it will be reset later. + tumblerPrivate->ignoreCurrentIndexChanges = true; // Set this after setting the delegate to avoid unexpected currentIndex changes: QTBUG-79150 m_listView->setHighlightRangeMode(QQuickListView::StrictlyEnforceRange); m_listView->setHighlightMoveDuration(1000); + tumblerPrivate->ignoreCurrentIndexChanges = false; + + // Reset the view's current index when creating the view: + // Setting highlight range mode causes geometry change, and + // then the view considers the viewport has moved (viewportMoved()). + // The view will update the currentIndex due to the viewport movement. + // Here, we check that if the view's currentIndex is not the same as it is + // supposed to be (the initial value), and then reset the view's currentIndex. + if (m_listView->currentIndex() != tumblerPrivate->currentIndex) + m_listView->setCurrentIndex(tumblerPrivate->currentIndex); qCDebug(lcTumblerView) << "finished creating ListView"; } |
