aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2022-05-25 14:36:32 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2022-06-04 17:45:09 +0200
commit2b6951017e4a9de20ff32d8eb7d7af9283bc0526 (patch)
treeacceb43e1eed1813188a9d953b1251d1c100553f /src
parenta526bb3a192f68580e60c1d4b8626e78a10483fe (diff)
QQuickTreeViewDelegate: remove selection on pointer click
Removing the selection after a pointer click is normally done by TableView. But since TreeViewDelegate accepts mouse events, it needs to do this explicitly. Change-Id: Id0d6879f5b0e014aa05f50487f89dd0a08bb21f5 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/quicktemplates2/qquicktreeviewdelegate.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquicktreeviewdelegate.cpp b/src/quicktemplates2/qquicktreeviewdelegate.cpp
index e3015a59d5..44e36a277d 100644
--- a/src/quicktemplates2/qquicktreeviewdelegate.cpp
+++ b/src/quicktemplates2/qquicktreeviewdelegate.cpp
@@ -343,8 +343,11 @@ void QQuickTreeViewDelegate::mousePressEvent(QMouseEvent *event)
}
const bool interactOnPress = !treeView()->isInteractive();
- if (interactOnPress && contains(event->position()))
+ if (interactOnPress && contains(event->position())) {
d->setCurrentIndex(event->position());
+ if (d->m_treeView && d->m_treeView->selectionModel())
+ d->m_treeView->selectionModel()->clearSelection();
+ }
QQuickAbstractButton::mousePressEvent(event);
}
@@ -360,8 +363,11 @@ void QQuickTreeViewDelegate::mouseReleaseEvent(QMouseEvent *event)
}
const bool interactOnRelease = treeView()->isInteractive();
- if (interactOnRelease && contains(event->position()))
+ if (interactOnRelease && contains(event->position())) {
d->setCurrentIndex(event->position());
+ if (d->m_treeView && d->m_treeView->selectionModel())
+ d->m_treeView->selectionModel()->clearSelection();
+ }
QQuickAbstractButton::mouseReleaseEvent(event);
}