Qt/QML: MouseArea in Flickable does not signal released/clicked when tapped on Touch Screen after upgrade

1.5k views Asked by At

After upgrade from Qt 5.4.1 to 5.9.1 the following code has changed behavior when using a touchscreen:

import QtQuick 2.1
import QtQuick.Window 2.2

Window {
    visible: true
    width: flick.width + 2*grid.spacing
    height: flick.height + 2*grid.spacing

    property int rectHeight: 65
    property int rectWidth: 100

    Flickable {
        id: flick
        pressDelay: 100
        contentWidth: grid.width
        anchors {
            top: parent.top
            left: parent.left
            leftMargin: grid.spacing
            topMargin: grid.spacing
        }

        height: rectHeight * grid.rows + grid.spacing * (grid.rows-1)
        width: rectWidth * (3 + 0.5) + grid.spacing * 3

        Grid {
            id: grid
            rows: 6
            columns: 12
            spacing: 12

            Repeater {
                id: repeater
                model: parent.rows * parent.columns
                Rectangle {
                    color: "#3333FF"
                    width: rectWidth
                    height: rectHeight

                    MouseArea {
                        anchors.fill: parent
                        onPressed: console.log("onPressed")
                        onReleased:console.log("onReleased")
                        onClicked: console.log("onClicked")
                    }
                }
            }
        }
    }
}

Previously with Qt 5.4.1 and using mouse or touchscreen to click a Rectangle it prints:

qml: onPressed
qml: onReleased
qml: onClicked

Currently with Qt 5.9.1 and using mouse it still works the same when clicking the rectangle:

 qml: onPressed
 qml: onReleased
 qml: onClicked

But with Qt 5.9.1 and using a touchscreen to click a Rectangle it only prints

 qml: onPressed

Not sure why the signals released and clicked are no longer emitted when using a touchscreen, but for my code I still need them to be emitted.

If I change

pressDelay: 0

Then the mouseArea emitted all 3 signals when clicked, but this is not a solution for me since this results in the pressed signal getting emitted from the mousearea when flicking.

0

There are 0 answers