import Qt 4.7 import Qt.labs.gestures 2.0 Rectangle { id:joystick2 property int xv:(knob.x-(width-knob.width)/2)*(200/(width-knob.width)) property int yv:(knob.y-(height-knob.height)/2)*(200/(height-knob.height)) width: 200 height: 200 Text { id: xtext text:xv } Text { id: ytext x:40 text: yv } Text { id: msg x:100 text: "" } Rectangle { id:knob x:parent.width/2-width/2 y:parent.width/2-height/2 width:20; height:20; color:"black" } GestureArea { anchors.fill: parent focus: true // Only some of the many gesture properties are shown. See Gesture documentation. /* Default { onStarted: console.log("onStarted pos = (",gesture.position.x,",",gesture.position.y,")") onFinished:console.log("onFinished pos = (",gesture.position.x,",",gesture.position.y,")") onUpdated: console.log("onUpdated pos = (",gesture.position.x,",",gesture.position.y,")"); } */ /* Tap { onStarted:console.log("tap onStarted pos = (",gesture.position.x,",",gesture.position.y,")") onFinished:console.log("tap onFinished pos = (",gesture.position.x,",",gesture.position.y,")") onUpdated:{ console.log("tap onUpdated pos = (",gesture.position.x,",",gesture.position.y,")"); // msg.text=gesture.position.x+","+gesture.position.y } } //onTapAndHold: // console.log("tap and hold pos = (",gesture.position.x,",",gesture.position.y,")") */ Pan { onStarted: console.log("pan onStarted delta = (",gesture.delta.x,",",gesture.delta.y,") acceleration = ",gesture.acceleration) onFinished:console.log("pan onFinished delta = (",gesture.delta.x,",",gesture.delta.y,") acceleration = ",gesture.acceleration) onUpdated: { console.log("pan onUpdated pos = (",gesture.delta.x,",",gesture.delta.y,")"); msg.text=gesture.delta.x+","+gesture.delta.y; } } /* onPinch: console.log("pinch center = (",gesture.centerPoint.x,",",gesture.centerPoint.y,") rotation =",gesture.rotationAngle," scale =",gesture.scaleFactor) onSwipe: console.log("swipe angle=",gesture.swipeAngle) onGesture: console.log("gesture hot spot = (",gesture.hotSpot.x,",",gesture.hotSpot.y,")") */ } }