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

QML Flickable stealing touch events from PinchArea

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 6.2.10, 6.5.0, 6.6.0
    • 5.13.0, 5.15.0
    • None
    • Qt 5.13 - Qt 5.15 on Windows, Android and Linux X11
    • Android, Linux/X11, Windows
    • 5171bcd9c (dev), f00edf756 (6.5), 9b00d83b1 (tqtc/lts-6.2)

    Description

      In the example below (taken from the official [Qt Example](https://doc.qt.io/qt-5.12/qtquick-touchinteraction-pincharea-flickresize-qml.html):
       
      main.qml

       

      import QtQuick 2.13
      import QtQuick.Controls 2.13
      ApplicationWindow {
       visible: true
       width: 640
       height: 480
       title: qsTr("Flickable Image Zoom Example")
      Flickable {
       id: flick
       anchors.fill: parent
       contentWidth: 500
       contentHeight: 500
      PinchArea {
       id: pinchArea
       width: Math.max(flick.contentWidth, flick.width)
       height: Math.max(flick.contentHeight, flick.height)
      property real initialWidth
       property real initialHeight
       onPinchStarted: {
       initialWidth = flick.contentWidth
       initialHeight = flick.contentHeight
       }
      onPinchUpdated: {
       // adjust content pos due to drag
       flick.contentX += pinch.previousCenter.x - pinch.center.x
       flick.contentY += pinch.previousCenter.y - pinch.center.y
      // resize content
       flick.resizeContent(initialWidth * pinch.scale, initialHeight * pinch.scale, pinch.center)
       }
      onPinchFinished: {
       // Move its content within bounds.
       flick.returnToBounds()
       }
      Rectangle {
       width: flick.contentWidth
       height: flick.contentHeight
       color: "white"
       Image {
      function fitToScreen() {
       var s = Math.min(flick.width / width, flick.height / height, 1)
       pinchArea.pinch.minimumScale = s
       }
      anchors.fill: parent
       fillMode: Image.PreserveAspectFit
       source: "qrc:/messi.jpg"
       onStatusChanged: {
       if(status == Image.Ready)
       fitToScreen()
       }
      MouseArea {
       id: mouseArea
       anchors.fill: parent
       }
       }
       }
       }
       }
       Button{
       text: mouseArea.enabled ? "MouseArea Enabled" : "MouseArea Disabled"
       onClicked: mouseArea.enabled = !mouseArea.enabled
       }
      }
      

       

       

       

      The user is unable to zoom using pinch gestures about 90% because the `Flickable` steals all the events from `PinchArea`. In order to make the `PinchArea` work 100% it is necessary to insert a `MouseArea` inside the `PinchArea`. In my code, I have inserted a button which toggles a `MouseArea` inside the `PinchArea` and testing I can confirm that the `PinchArea` only works correctly when the `MouseArea` is enabled. Another example of this bug can be found on my [Stackverflow post](https://stackoverflow.com/questions/57503125/qml-pincharea-not-working-as-expected-with-qml-flickable).

      I have also attached a video of the issue.

      Attachments

        1. main.qml
          2 kB
        2. pinchbug.mp4
          2.05 MB

        Issue Links

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

          Activity

            People

              srutledg Shawn Rutledge
              daljit97 Daljit Singh
              Votes:
              4 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews