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

Bug on DragHandler with mouse buttons

    XMLWordPrintable

Details

    • Linux/X11, Windows
    • 1982d1b1aa55ae44a1a775a5745e5c2f11001398 (qt/qtdeclarative/5.12)

    Description

      Hello,

      I think there is a bug with DragHandler.

      I have encountered it on 5.12 and it still persists on 5.13.
      It seems like the acceptedButtons property has no effect and the drag occurs whatever button has been pressed.

      See below a minimalist code (main.cpp and the main.qml) in order to reproduce the issue.

      // main.cpp
      #include <QGuiApplication>
      #include <QQmlApplicationEngine>
      
      int main(int argc, char *argv[])
      {
          QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
      
          QGuiApplication app(argc, argv);
      
          QQmlApplicationEngine engine;
          const QUrl url(QStringLiteral("qrc:/main.qml"));
          QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                           &app, [url](QObject *obj, const QUrl &objUrl) {
              if (!obj && url == objUrl)
                  QCoreApplication::exit(-1);
          }, Qt::QueuedConnection);
          engine.load(url);
      
          return app.exec();
      }
      
      // main.qml
      import QtQuick 2.12
      import QtQuick.Window 2.12
      
      Window
      {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          Rectangle
          {
              id : dragable
      
              x: 100
              y: 100
              width: 200
              height: 200
              color: "blue"
      
              DragHandler
              {
                  id: dragHandlerID
                  acceptedButtons: Qt.RightButton
                  onActiveChanged:
                  {
                      console.log("Drag is activated");
                  }
              }
          }
      }
      
      

       

      In the code above, "Drag is activated" is printed even if drag is performed with left button.

      Tks in advance for your help.

      Attachments

        Issue Links

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

          Activity

            People

              srutledg Shawn Rutledge
              nitroboy Nassim NALL
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes