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

Using TapHandler in a QML Dialog incorrectly propagates mouse events to DragHandler

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.15, 6.3.0 Alpha
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      I've tested this with Qt 5.15.2 and Qt 6.3.0 Alpha on Linux and Windows. On Qt 6.3.0, the situation is slightly better since the image is dragged by a small amount and then stops.
    • Platform/s:
      Linux/X11, Windows

      Description

      In the following code we have a dialog over an Image with a DragHandler:

      import QtQuick 2.15
      import QtQuick.Window 2.15
      import QtQuick.Controls 2.15
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          Image{
              width: 1000
              height: 600
              source: "https://testimages.org/img/testimages_screenshot.jpg"
              DragHandler{
                  grabPermissions: PointerHandler.CanTakeOverFromHandlersOfSameType
              }
          }
          Dialog{
              id: randomDialog
              title: "Random dialog"
              standardButtons: Dialog.Cancel | Dialog.Ok
              anchors.centerIn: parent
              closePolicy: Dialog.CloseOnEscape
              clip: true
              modal: true
              width: 500; height: 500
      
              GridView{
                  anchors.centerIn: parent
                  width: 400; height: 400
                  model: 100
                  delegate: Rectangle{
                      width: 400
                      height: 400
                      Label{text: index;}
                      TapHandler{
                          id: tapHandler
                      }
                  }
              }
          }
          Component.onCompleted: randomDialog.open()
      }

      If you run the code, open the dialog and drag the list in short busts inside the dialog, you'll see that the image underneath is also moving. If you remove the TapHandler (or use MouseArea instead) from the delegates, then the code behaves as expected: the image underneath is not dragged while flicking the list. It seems that DragHandler is weirdly stealing the input events from the TapHandler. This behaviour practically makes TapHandler quite hard to use inside dialog. Also if you replace the Image with a Flickable, the situation is even worse.

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              srutledg Shawn Rutledge
              Reporter:
              daljit97 Daljit Singh
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:

                  Gerrit Reviews

                  There are no open Gerrit changes