From 88047be4ecb99799f4876ff3e7001abe34ac29bc Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Tue, 5 Nov 2019 07:49:48 +0100 Subject: QAbstractItemView: don't toggle selection on mouse move on some index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In single selection mode, the current selection toggled when the user pressed the left mouse + Ctrl key and then moved the mouse over the item. This was introduced with 28a21d98ef8d880a6dd86ee19dd803424bb5eae1 which added the possibility to deselect an item in single selection mode. Fix it by adding a check if the event was a mouse move event and use the old codepath for it. Fixes: QTBUG-77353 Change-Id: Id845ada302c92646885dfd966721b00d940f1260 Reviewed-by: Thorbjørn Lund Martsum --- src/widgets/itemviews/qabstractitemview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets/itemviews') diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index c2afed775c..b1557e9af4 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -3967,7 +3967,7 @@ QItemSelectionModel::SelectionFlags QAbstractItemView::selectionCommand(const QM case SingleSelection: // ClearAndSelect on valid index otherwise NoUpdate if (event && event->type() == QEvent::MouseButtonRelease) return QItemSelectionModel::NoUpdate; - if ((keyModifiers & Qt::ControlModifier) && d->selectionModel->isSelected(index)) + if ((keyModifiers & Qt::ControlModifier) && d->selectionModel->isSelected(index) && event->type() != QEvent::MouseMove) return QItemSelectionModel::Deselect | d->selectionBehaviorFlags(); else return QItemSelectionModel::ClearAndSelect | d->selectionBehaviorFlags(); -- cgit v1.2.3