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

QQuickWidget doesn't receive mouse events when not at topleft corner of window

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P0: Blocker
    • Resolution: Done
    • Affects Version/s: 5.9
    • Fix Version/s: 5.9.4, 5.10.1
    • Component/s: Quick: Widget
    • Labels:
      None
    • Commits:
      f6313ef4c29a0efa45667dca9c513508466ad250 (qtdeclarative/5.9.4, 17.1.2018, 5.9.4)

      Description

      Consider:

      #include <QApplication>
      #include <QDockWidget>
      #include <QQuickWidget>
      #include <QMainWindow>
      #include <QTimer>
      
      class MainWindow : public QMainWindow
      {
          Q_OBJECT
      
      public:
          explicit MainWindow(QWidget *parent = 0) :
              QMainWindow(parent)
          {
              resize(1024, 1024);
              QWidget *dock = new QWidget(this);
              QQuickWidget *quick = new QQuickWidget(dock);
              quick->setSource(QUrl("qrc:/main.qml"));
              dock->setFocusProxy(quick);
              dock->move(512, 512);
          }
      };
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          MainWindow w;
          w.show();
      
          return a.exec();
      }
      
      #include <main.moc>
      

      and

      import QtQuick 2.0
      
      Rectangle {
          width: 500
          height: 500
      
          color: "green"
      
          MouseArea {
              anchors.fill: parent
              onClicked: console.log("clicked")
          }
      }
      

      Clicking on the green rectangle should trigger "clicked" console messages but doesn't. When the "dock->move(512, 512);" line is removed the green rectangle is in the top left of the window and clicking on it triggers the messages.

      This is because https://codereview.qt-project.org/#/c/213030/ changed the coordinates of mouse events sent to QQuickWidget. Previously localPos was also assumed as windowPos, now the original windowPos of the event is passed, which doesn't fit the offscreen Quick Window.

        Attachments

          Issue Links

          For Gerrit Dashboard: QTBUG-65800
          # Subject Branch Project Status CR V

            Activity

              People

              • Assignee:
                ulherman Ulf Hermann
                Reporter:
                ulherman Ulf Hermann
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes