如何在QML中使用multitouch
来源:互联网 发布:淘宝批量下架宝贝 编辑:程序博客网 时间:2024/06/05 11:24
在Qt QML中,它可以利用multitouch来做一些我们想做的事情。在今天的文章中,我们将介绍如何使用multitouch来做一些我们想做的事。
其实,在QML中利用多点触控是非常容易的一件事。我们下面直接来展示我们的例程来给大家讲解一下:
import QtQuick 2.0import Ubuntu.Components 1.1/*! \brief MainView with a Label and Button elements.*/MainView { // objectName for functional testing purposes (autopilot-qt5) objectName: "mainView" // Note! applicationName needs to match the "name" field of the click manifest applicationName: "multitouchtest.liu-xiao-guo" /* This property enables the application to change orientation when the device is rotated. The default is false. */ //automaticOrientation: true // Removes the old toolbar and enables new features of the new header. useDeprecatedToolbar: false width: units.gu(60) height: units.gu(85) Page { title: i18n.tr("multitouchtest") MultiPointTouchArea { anchors.fill: parent touchPoints: [ TouchPoint { id: point1 }, TouchPoint { id: point2 }, TouchPoint { id: point3 }, TouchPoint { id: point4 } ] } Image { width: parent.width/5 height: parent.height/5 source: "images/image1.jpg" x: point1.x y: point1.y } Image { width: parent.width/5 height: parent.height/5 source: "images/image2.jpg" x: point2.x y: point2.y } Image { width: parent.width/5 height: parent.height/5 source: "images/image3.jpg" x: point3.x y: point3.y } Image { width: parent.width/5 height: parent.height/5 source: "images/image4.jpg" x: point4.x y: point4.y } }}
如上面的介绍的那样,我们定义了一个“MultiPointTouchArea”。我们在Image中,绑定它们的坐标和TouchPoint在一起。这样,TouchPoint的坐标变化时,Image可以随时移动。 在它的里面,我们同时定义了4个TouchPoint。当我们只有一个手指触屏时,我们可以看见只有image1.jpg可以随着我们的手指移动:
当我们同时两个手指触屏时,我们可以看到同时可以有两个图片image1.jpg及image2.jpg来同时移动我们的画面:
同时3个手指触屏时,我们可以看到3个照片同时出现在屏幕上,并随我们的手指移动:
整个项目的源码在:https://github.com/liu-xiao-guo/multitouchtest
0 0
- 如何在QML中使用multitouch
- 如何在Ubuntu QML应用中使用Push Notification
- 如何在QML应用中使用Javascript解析JSON
- 如何在QML应用中使用Javascript来解析XML
- 如何在QML中使用camera API来拍照
- 如何在QML中使用不同的字体(font)
- 在QML中使用定时器
- 在QML中使用alarm
- 如何在QML应用中读写文件
- 如何在QML应用中启动Scope
- 如何在QML中定义Javascript资源
- 如何在QML中定义Javascript资源
- QML基础——在C++程序中使用QML
- QML基础——在C++程序中使用QML
- QML基础——在C++程序中使用QML
- QML基础——在C++程序中使用QML
- QML基础——在C++程序中使用QML
- QML基础——在C++程序中使用QML
- hdu1106 排序 (分割字符串)
- IOS开发—自定义多选相册
- SqlServer 常用语句
- linux 学习步骤
- oracle时间格式转换,如yyyy-mm-dd改成yyyy-mm-dd 23:59:59
- 如何在QML中使用multitouch
- SVM算法入门
- 接口和抽象类
- NTFS for Mac如何安装
- Fiddler使用教程
- 单例模式
- C语言常见面试题(经典中的经典)
- 自定义AlertDialog的创建和使用
- NTFS For Mac 破解版下载