diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-06-07 22:51:02 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-06-09 23:28:24 +0200 |
commit | 8f3dca45556f536be36e943b6f1f0e65ef9eb93b (patch) | |
tree | 706ffb5cff8dfb23824b5d96211482b4730b89fc /src/widgets | |
parent | 0f63509353c2ff1df3b38f31f9a7b966e1deff2b (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
Change-Id: I3e0a18a6a179d80b9d810fce5aa658f0cfff9a29
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit b1fdcc8c0fefe0660302494618032342b623e199)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/itemviews/qabstractitemview.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 8a6c197b5d..120509fddd 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(); |