Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.6.0, 5.12.0, 5.12.1, 5.12.2, 5.12.3
-
None
Description
There's an issue in QAbstractItemView::selectionCommand where if selectionMode is set to SingleSelection, releasing the mouse will always signal for no update. This presents a problem when an item is selected and wanting to deselect by clicking on empty space in the view since it'll never be deselected (NoUpdate). This goes against documentation which states "It is possible for the user to deselect the selected item.".
Mouse release on empty space should in fact deselect the current item as it does in other SelectionModes.
We currently had to work around this issue by overriding the mouseReleaseEvent on our view to cache the selection mode, switch to ExtendedSelection, call QAbstractItemView::mouseRelease... and then set selectionMode back to it's original state.
Repro & sample code:
// Repro steps: // - Select an item in the list // - Try to deselect by clicking on empty space // - Notice that items on single selection cannot be deselected // - Switch selection mode to ExtendedSelection and see required behavior when clicking on empty space QListView* pListView = new QListView(); // Switch to extended selection to see required behavior pListView->setSelectionMode(QAbstractItemView::SingleSelection); // Use a ready-to-use model for a quick sample QFileSystemModel* pFileSystemModel = new QFileSystemModel(); pFileSystemModel->setRootPath(QDir::currentPath()); pListView->setModel(pFileSystemModel);