1、QtQuick 1 vs QtQuick2
二者还是有很大区别的,无论从模块重组还是从底层实现,均需注意。下面是两个官方文档给出的差别说明及列表:
2、Qt.labs.gestures
- 虽然没有正式的Release模块(
Types in the Qt.labs module are not guaranteed to remain compatible in future versions.
),但在qt4.8中,提供了一个gesture特性的试验模块。 - 此外,还有一个开发者写的非官方文档可供了解gesture模块开发的背景及主要接口、属性及函数:Getting in touch with Qt Quick: Gestures and QML。
- 但,我们依然要注意,在qt文档中给出如下说明:
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.
- 此外,附上一个git网址,里面全是Qt libs特性的实验项目,你可以找到自己需要的模块。不过有一些项目已经很久没有更新了。例如这里讨论的gestures。
所以,在实际项目中,需要权衡一下,或者找到替代方案!!! - 实验特性实现文件在qt5当中的路径为:xxx/qt5.3.1/qtbase/qml/Qt/labs。
目前只有2个内置特性模块:settings和folderlistmodel。 - 另外:Qt Sensor Gestures也有与手势相关的传感器的内容。
- 在qt5.3中的开发文档中,亦有相关的demo,路径为:
xxx/qt5.3.1/qtquick1/examples/declarative/touchinteraction
。
目录下面有3个例子:一个是关于gesture的,一个是鼠标域(MouseArea)的,一个是弹碰域(PinchArea)的。
3、官方demo
import QtQuick 1.0 import Qt.labs.gestures 1.0 // Only works on platforms with Touch support. Rectangle { id: rect width: 320 height: 180 Text { 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,")") } }
QML手势相关的实验模块:Qt.labs.gestures模块介绍
时间: 2024-10-13 16:34:34