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

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15, 6.3.0 Alpha
    • None
    • 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.
    • 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

        1. bug.mkv
          3.85 MB
          Daljit Singh

        Issue Links

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

          Activity

            People

              srutledg Shawn Rutledge
              daljit97 Daljit Singh
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There is 1 open Gerrit change