From b1fdcc8c0fefe0660302494618032342b623e199 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 7 Jun 2021 22:51:02 +0200 Subject: 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 --- src/widgets/itemviews/qabstractitemview.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/widgets/itemviews') 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(); -- cgit v1.2.3