1. qtquick 1 vs qtquick2
The two are quite different. You must pay attention to both the module restructuring and the underlying implementation. The following are the differences and lists in the two official documents:
- Differences
- Difference list
2. QT. Labs. gestures
Although there is no formal release module (Types in the Qt.labs module are not guaranteed to remain compatible in future versions.
), But in qt4.8, a test module with the gesture feature is provided.
In addition, there is an unofficial document written by the developer to learn about the background and main interfaces, attributes, and functions of the gesture module development: getting in touch with QT quick: gestures and qml.
However, we still need to pay attention to the following instructions in the QT document:
Warning: GestureArea is an experimental element whose development has been discontinued. PinchArea is available in QtQuick 1.1 and handles two finger gesture input.
Note: This element is only functional on devices with touch input.
In addition, we have attached a git website, which contains all experimental projects with QT libs features. You can find the modules you need. However, some projects have not been updated for a long time. For example, gestures discussed here.
Therefore, in actual projects, you need to weigh the balance or find an alternative solution !!!
The path of the experiment implementation file in qt5 is xxx/qt5.3.1/qtbase/qml/QT/labs.
Currently, there are only two built-in feature modules: settings and folderlistmodel.
In addition, QT sensor gestures also contains gesture-Related Sensors.
In the development documentation of qt5.3, there are also related demos. The path is:xxx/qt5.3.1/qtquick1/examples/declarative/touchinteraction
.
There are three examples in the directory: one is about gesture, the other is the mouse field (mousearea), and the other is the pincharea field.
3. Official demo
import QtQuick 1.0import Qt.labs.gestures 1.0// Only works on platforms with Touch support.Rectangle {id: rectwidth: 320height: 180Text { anchors.centerIn: parent text: "Tap / TapAndHold / Pan / Pinch / Swipe\nOnly works on platforms with Touch support." horizontalAlignment: Text.Center}GestureArea { anchors.fill: parent focus: true // Only some of the many gesture properties are shown. See Gesture documentation. onTap: console.log("tap pos = (",gesture.position.x,",",gesture.position.y,")") onTapAndHold: console.log("tap and hold pos = (",gesture.position.x,",",gesture.position.y,")") onPan: console.log("pan delta = (",gesture.delta.x,",",gesture.delta.y,") acceleration = ",gesture.acceleration) 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,")")}}