Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. MultiPointTouchArea onTouchUpdated remove all touchPoints
Forum Updated to NodeBB v4.3 + New Features

MultiPointTouchArea onTouchUpdated remove all touchPoints

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NULL.Player
    wrote on last edited by NULL.Player
    #1

    Hello!
    First sorry for my english,
    I want to use MultiPointTouchArea, but it work works is not, as I think. For my trouble, I write a test code, like that(sorry, I don't understand the code layout in there):

    import QtQuick 2.0
    
    Rectangle {
        id: main
        color: "#11262B"
        width: 800
        height: 600
    
        // Visual presentation of the touch points
        Repeater {
            id: touchBalls
            model: multiArea.points
    
            Item {
                x: modelData.x
                y: modelData.y
    
                Rectangle {
                    anchors.centerIn: parent
                    color: "white"
                    opacity: 0.1
                    width: 1000 * modelData.pressure
                    height: width
                    radius: width / 2
                }
    
                Rectangle {
                    anchors.centerIn: parent
                    color: "#20cc2c"
                    opacity: modelData.pressure * 10
                    width: 100
                    height: width
                    radius: width / 2
                }
            }
        }
    
        // Text presentation of the touch points
        Column {
            spacing: 10
    
            Repeater {
                model: multiArea.points
                Text {
                    font.pointSize: 12
                    color: "snow"
                    text: "{ id: " + modelData.pointId + " x: " + modelData.x + ", y: " + modelData.y +
                          ", pressure: " + modelData.pressure + " }"
                }
            }
        }
    
        // http://doc.qt.nokia.com/qt5/qml-qtquick2-multipointtoucharea.html
        MultiPointTouchArea {
            id: multiArea;
    
            property variant points: []
    
            function printTouchPoints(tps) {
                for (var i = 0; i < tps.length; ++ i) {
                    console.log("id:", tps[i].pointId, ", (x, y): (", tps[i].x, tps[i].y, ")");
                }
            }
    
            anchors.fill: parent;
    
            minimumTouchPoints: 1;
            maximumTouchPoints: 5;
    
            // Each of the event handlers have "touchPoints" available
            // http://doc.qt.nokia.com/qt5/qml-qtquick2-touchpoint.html
            onGestureStarted: {
                console.log("multiArea onGestureStarted.", "getsture:", gesture.objectName);
            }
            onUpdated: {
                console.log("multiArea onUpdated.", "touchPoints:", touchPoints.length, points.length);
                points = touchPoints;
                printTouchPoints(touchPoints);
            }
            onTouchUpdated: {
                console.log("multiArea onTouchUpdated.", "touchPoints:", touchPoints.length, points.length);
                points = touchPoints;
                printTouchPoints(touchPoints);
            }
            onPressed: {
                console.log("multiArea onPressed.", "touchPoints:", touchPoints.length, points.length);
                points = touchPoints;
                printTouchPoints(touchPoints);
            }
            onReleased: {
                console.log("multiArea onReleased.", "touchPoints:", touchPoints.length, points.length);
                points = touchPoints;
                printTouchPoints(touchPoints);
            }
            onCanceled: {
                console.log("multiArea onCanceled.", "touchPoints:", touchPoints.length, points.length);
                points = touchPoints;
                printTouchPoints(touchPoints);
            }
        }
    }
    

    the problem appear after the steps:

    1. touch the mobile screen use your one finger
    2. touch the mobile screen use your second finger
    3. remove the second finger from mobile screen

    now, the console and the mobile print told you the touchPoints.length is 0,
    but my first finger put still on screen.
    So, how it work normal, thank you in advance.

    Edited: Use ``` (3 backticks) - p3c0

    1 Reply Last reply
    0
    • N Offline
      N Offline
      NULL.Player
      wrote on last edited by
      #2

      Now I know some reason, that code work normal in QQuickView, bu I need QQuickWidget. When I remove second finger in QQuickWidget, MultiPointTouchArea will correspond handing is onCanceled, the Qt document tell me, "This signal is emitted when new touch events have been canceled because another item stole the touch event handling",
      Now, should I how to avoid "stole the touch"?

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved