Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-110719

QQuickItem::setCursor() doesn't work in QGraphicsView without mouse event

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 6.5.0 Beta2
    • None
    • All

      Try the attached example ( qquickwidget-cursor.tgz ) to reproduce: move the mouse cursor above the rectangle and press space to change mouse cursor. It doesn't work with QGraphicsView. See the comments in mainwindow.cpp.

      This example looks artificial and pointless but this mimics QtWebEngine behavior:

      • QQuickWidget handles events.
      • Mouse events are not handled by the default Qt implementation (they are forwarded to Chromium in QtWebEngine).
      • In this example, I use keyboard event for triggering the cursor change because using mouse events would complicate things even further.

      The QtWebEngine issue is this: https://bugreports.qt.io/browse/QTBUG-108284

      Cursor position and item geometry is verbosed in the example. As far as I can see, the problem is that it is not detected properly whether the mouse cursor is above the item if it is inside a QGraphicsView. See QQuickItem::setCursor() implementation:

      diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
      index 5b293afaa3..c2ebafdb3a 100644
      --- a/src/quick/items/qquickitem.cpp
      +++ b/src/quick/items/qquickitem.cpp
      @@ -8025,7 +8025,7 @@ void QQuickItem::setCursor(const QCursor &cursor)
                   QWindow *renderWindow = QQuickRenderControl::renderWindowFor(d->window);
                   QWindow *window = renderWindow ? renderWindow : d->window;
                   QPointF pos = window->mapFromGlobal(QGuiApplicationPrivate::lastCursorPosition);
      -            if (contains(mapFromScene(pos)))
      +            if (contains(mapFromScene(pos))) // <- This should not return false.
                       updateCursorPos = pos;
               }
           }
      

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            pvarga Peter Varga
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes