Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

MultiPointTouchArea problem. Letting single touches through.



  • Hello everyone,

    I know this has been asked a lot, but i could not find any answers how to really work around this problem so here it goes.

    I'm trying to make MultiPointTouchArea overlay on my software, so that it would catch Gesture events with 2 or more fingers. The problem is that when i set the z value to something like 99, every MouseArea is left below it. It seem's that when using normal mouse this is no problem cause i can set MultiPointTouchArea mouseEnabled value to false, so it lets mouseEvents through, but with touchscreen this doesn't work because of the TouchArea doesn't see one finger touch as a mouseEvent.

    Has anyone come up with any way to reimplement the MultiPointTouchArea so it would have something like MouseArea with the propagateComposedEvents, or that when it catches a touchEvent it would re-send same event to lower levels?

    Thanks in advance,
    -Izba


  • Qt Champions 2017

    In your case handle onPressed(...) signal in touchArea and emit user defined signal. Catch this user defined signal in lower layer objects.


  • Moderators

    @Izba
    you can set the propagateComposedEvents property to true.

    http://doc.qt.io/qt-5/qml-qtquick-mousearea.html#propagateComposedEvents-prop

    that however may only apply to "normal" mouseAreas, I'm unsure.



  • Hi @dheerendra ,

    Well yeah i could use onPressed signal and turn it to other signal, but that's not very effective when i have big layout under the MultiPointTouchArea.

    @J-Hilk

    I tried that even with the mouseArea on top of MultiPointTouchArea. It doesn't work with the propagateComposedEvents. This way it only takes the mouseArea event and MultiPointTouchArea, doesn't see any touch events.


  • Qt Champions 2017

    @lzba, you are right. It is not so good way. However that is the only option. We may need to write some generic component to take care of this.



  • @dheerendra, is there a way to listen to a touch device by a c++ class and get those multipoint touches without stealing it? Cause it really doesn't have to be full screen MultiPointTouchArea, if i could just listen to raw input data and calculate gestures from that. I tried to look at QTouchDevice, but that class, doesn't give me any raw data, only names and capabilities.


  • Qt Champions 2017

    It may not be direct. It may be round about way of doing the things. You can use eventFilters and try catching the events. Filter the events of your interest.



  • MultiPointTouchArea's minimumTouchPoints property set to 2 doesn't work?



  • @dheerendra, well ill try to scrape events straight from /dev/input/event0.

    @Larvae, No it still doesn't let one finger touches trough.

    Ill try to make solution for this problem and come back with it later.



  • How about this? It works for click and release, but I have some trouble with pressed:

    import QtQuick 2.11
    import QtQuick.Window 2.11
    
    Window {
        id: root
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        
        Text {
            id: text
            text: "No Input"
        }
        
        MouseArea{
            id: m1
            z:1
            anchors.fill: parent
            onClicked: {
                console.log("Click!")
            }
            onPressed: {
                text.text = "MouseAreaPressed at x=" + mouse.x + " y=" +mouse.y
                console.log("Pressed!")
            }
            onReleased: {
                text.text = "No Input"
                console.log("Released!")
            }
        }
        
        MultiPointTouchArea {
            id: multiPointArea
            z:2
            anchors.fill: parent
            maximumTouchPoints: 2
            minimumTouchPoints: 2
            onPressed: {
                text.text = "Multi Point Input Pressed"
            }
            onReleased: text.text = "No Input"
            MultiPointTouchArea {
                id: singlePointArea
                anchors.fill: parent
                maximumTouchPoints: 1
                minimumTouchPoints: 1
                touchPoints: TouchPoint { id: point }
                onPressed: {
                    text.text = "Single Point Input Pressed"
                    multiPointArea.visible = false
                    var item = parent.parent.childAt(point.x, point.y)
                    multiPointArea.visible = true
                    console.log(item)
                    if (item && typeof(item["clicked"]) === "function") {
                        item["clicked"](point);
                    }
                }
                onReleased:  //text.text = "No Input"
                {
                    text.text = "No Input"
                    var item2 = parent.parent.childAt(point.x, point.y).nextItemInFocusChain(true)
                    multiPointArea.visible = false
                    var item = parent.parent.childAt(point.x, point.y)
                    multiPointArea.visible = true
                    console.log(item)
                    if (item && typeof(item["released"]) === "function") {
                        item["released"](point);
                    }
                }
            }
        }
    }  
    

Log in to reply