Deselect currently selected item if user clicks outside the list
Signed-off-by: crueter <crueter@eden-emu.dev>
This commit is contained in:
parent
ec8f3b6964
commit
1de431f915
|
|
@ -1277,6 +1277,17 @@ bool GameList::eventFilter(QObject* obj, QEvent* event) {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj == m_currentView->viewport() && event->type() == QEvent::MouseButtonPress) {
|
||||
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
|
||||
|
||||
// if the user clicks outside of the list, deselect the current item.
|
||||
QModelIndex index = m_currentView->indexAt(mouseEvent->pos());
|
||||
if (!index.isValid()) {
|
||||
m_currentView->selectionModel()->clearSelection();
|
||||
m_currentView->setCurrentIndex(QModelIndex());
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue