QML手势相关的实验模块:Qt.labs.gestures模块介绍

1、QtQuick 1 vs QtQuick2

二者还是有很大区别的,无论从模块重组还是从底层实现,均需注意。下面是两个官方文档给出的差别说明及列表:

  1. 差别说明
  2. 差别列表

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

<!-- lang: js -->
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,")")
}
}

转载于:https://my.oschina.net/xishvaigo/blog/295905

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值