Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

QML using QGLWidget as viewport not getting TouchEvents

$
0
0
My question is how can I send TouchEvents to widgets from a mouse driver plugin when a QGLWidget is the viewport and QML is being used. Using QT 4.7.4. I am using qmlviewer to run the tic-tac-toe example [qt-project.org] modified to support gestures (modified code is below). The program works fine when run using a frame buffer. However, when I try and use QGLWidget as the viewport the touch events are consumed in qt_translateRawTouchEvent. As best I can tell because no topLevel window is found. The approach to sending touch events is described in multitouch driver for QT embedded [qt-project.org] which calls qt_translateRawTouchEvent. Is there a better mechanism for sending touch events than qt_translateRawTouchEvent? Executing qmlviewer like this fails (note I don’t use experimentalgestures because the QML import, see below): export QWS_MOUSE_PROTO=LinuxXyz:/dev/input/event0 /etc/init.d/rc.pvr  start qmlviewer -qws -opengl -display powervr tic-tac-toe.qml Executing qmlviewer like this passes: export QWS_MOUSE_PROTO=LinuxXyz:/dev/input/event0 /etc/init.d/rc.pvr  start qmlviewer -qws tic-tac-toe.qml To debug this, code to walk the list of all widgets was added before calling qt_translateRawTouchEvent and that code indicates that all widgets except QGLWidget are hidden (not visible) and have position 0,0. If this is correct behavior then I believe it explains why qt_translateRawTouchEvent can’t find a widget to send the events to by calling topLevelAt function. There likely is another function to translate and send the touch event, would greatly appreciate a code snip or pointer in the right direction. Thank you, Aaron tic-tac-toe.qml Modified tic-tac-toe to support tap gesture instead of click. import QtQuick 1.0 import Qt.labs.gestures 1.0 import "content" import "content/tic-tac-toe.js" as Logic   Rectangle {     id: game       property bool running: true     property real difficulty: 1.0   //chance it will actually think       width: display.width; height: display.height + 10       Image {         id: boardImage         source: "content/pics/board.png"     }         Column {         id: display           Grid {             id: board             width: boardImage.width; height: boardImage.height             columns: 3               Repeater {                 model: 9                   TicTac {                     width: board.width/3                     height: board.height/3                         GestureArea {                     anchors.fill: parent                     focus: true                     onTap: { console.log("tap index=",index)                         if (game.running && Logic.canPlayAtPos(index)) {                             if (!Logic.makeMove(index, "X"))                                 Logic.computerTurn();                         }                     }                     }                 }             }         }           Row {             spacing: 4             anchors.horizontalCenter: parent.horizontalCenter               Button {                 text: "Hard"                 pressed: game.difficulty == 1.0                 onClicked: { game.difficulty = 1.0 }             }             Button {                 text: "Moderate"                 pressed: game.difficulty == 0.8                 onClicked: { game.difficulty = 0.8 }             }             Button {                 text: "Easy"                 pressed: game.difficulty == 0.2                 onClicked: { game.difficulty = 0.2 }             }         }     }         Text {         id: messageDisplay         anchors.centerIn: parent         color: "blue"         style: Text.Outline; styleColor: "white"         font.pixelSize: 50; font.bold: true         visible: false           Timer {             running: messageDisplay.visible             onTriggered: {                 messageDisplay.visible = false;                 Logic.restartGame();             }         }     } }

Viewing all articles
Browse latest Browse all 4972

Trending Articles