summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-06-07 22:51:02 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2021-06-09 18:19:15 +0200
commitb1fdcc8c0fefe0660302494618032342b623e199 (patch)
treeffaf547165816f08ec547f0de5129f6e919d71b1 /src/widgets
parent06b1e404c936847038cc7a371720b05f31532b6a (diff)
QAbstractItemView: block autoScroll from interfering with QScroller
When pressing an index in order to start a flick gesture, QAIV sets the current index. When QScroller changes state to Dragging, then QAIV restores the current index to what it was before the press, as the user is clearly scrolling the view. With autoScroll enabled, this will produce an ugly jump if the old current index is no longer in the viewport. To prevent this, disable autoScroll before restoring the currentIndex. Fixes: QTBUG-64543 Pick-to: 6.2 6.1 5.15 Change-Id: I3e0a18a6a179d80b9d810fce5aa658f0cfff9a29 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index 8a923e44a7..cfb6a3151a 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -224,7 +224,11 @@ void QAbstractItemViewPrivate::_q_scrollerStateChanged()
// restore the old selection if we really start scrolling
if (q->selectionModel()) {
q->selectionModel()->select(oldSelection, QItemSelectionModel::ClearAndSelect);
+ // block autoScroll logic while we are already handling scrolling
+ const bool wasAutoScroll = autoScroll;
+ autoScroll = false;
q->selectionModel()->setCurrentIndex(oldCurrent, QItemSelectionModel::NoUpdate);
+ autoScroll = wasAutoScroll;
}
Q_FALLTHROUGH();