path: root/src/widgets/graphicsview
diff options
authorVolker Hilsheimer <>2019-07-05 17:24:22 +0200
committerVolker Hilsheimer <>2019-07-08 20:51:22 +0200
commitd8688d44840dd3f2324769d10b927c442b42e2c0 (patch)
tree4166ae6ec8854b0c44e171fb144df4f7406601ac /src/widgets/graphicsview
parent307403f8b4f25f3fa711fb64102c755d50283c2b (diff)
Don't set the mouse cursor for items that are disabled
As with widgets, items that are disabled should not receive any input events. Similar to QGraphicsScene, which ignores disabled items when handling mouse presses, the view should also ignore them when handling mouse moves to update the cursor. Since QGraphicsView only adjusts the cursors on mouse moves, reenabling an item that is currently under the mouse will not change the cursor. This is consistent with other changes of item attributes that would position the item under the mouse (such as moving it). The overhead of hit-testing items for every such attribute change would be too large, and applications can generate a mouse move event if they really need to adjust the cursor in all situations. [ChangeLog][QtWidgets][QGraphicsView] Ignore disabled items when setting the mouse cursor. Fixes: QTBUG-76765 Change-Id: Ifcd31fc0581e8421e58eeb436a55b031909eed7e Reviewed-by: Shawn Rutledge <>
Diffstat (limited to 'src/widgets/graphicsview')
1 files changed, 2 insertions, 2 deletions
diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp
index 24647dd74c..b14b23909e 100644
--- a/src/widgets/graphicsview/qgraphicsview.cpp
+++ b/src/widgets/graphicsview/qgraphicsview.cpp
@@ -691,7 +691,7 @@ void QGraphicsViewPrivate::mouseMoveEventHandler(QMouseEvent *event)
// Find the topmost item under the mouse with a cursor.
foreach (QGraphicsItem *item, scene->d_func()->cachedItemsUnderMouse) {
- if (item->hasCursor()) {
+ if (item->isEnabled() && item->hasCursor()) {
@@ -808,7 +808,7 @@ void QGraphicsViewPrivate::_q_unsetViewportCursor()
const auto items = q->items(lastMouseEvent.pos());
for (QGraphicsItem *item : items) {
- if (item->hasCursor()) {
+ if (item->isEnabled() && item->hasCursor()) {