MultiPointTouchArea为qml中的多点触摸提供了最基本、最重要的支持,它与TouchPoint及相关域结合,可以说是qml中多点触摸的基石。

MultiPointTouchArea是不可见元素,它用来跟踪多点触摸。从Item继承过来的enabled属性用来标识触点操作是否有效。如果该属性为false,则触摸区域将忽略鼠标以及触摸事件。

默认情况下,鼠标的处理方式与单个触摸点的处理方式相同,触摸区域下的项目不会接收鼠标事件,因为触摸区域正在处理它们。 但是,如果mouseEnabled属性设置为false,则它对鼠标事件变得透明,以便可以使用另一个鼠标敏感项(例如MouseArea)分别处理鼠标交互。

MultiPointTouchArea有两种使用方式:

  • setting touchPoints to provide touch point objects with properties that can be bound to
  • using the onTouchUpdated or onPressed, onUpdated and onReleased handlers

Properties:

  • maximumTouchPoints : int 触点的最大数目
  • minimumTouchPoints : int 触点的最小数目
  • mouseEnabled : bool 是否响应鼠标点击事件(默认为true)
  • touchPoints : list 触点的容器

Signals

  • canceled(list touchPoints)
  • gestureStarted(GestureEvent gesture)
  • pressed(list touchPoints)
  • released(list touchPoints)
  • touchUpdated(list touchPoints)
  • updated(list touchPoints)

TouchPoint

用于描述MultiPointTouchArea中的触点。

###Properties:

  • area : rectangle
  • pointId : int
  • pressed : bool
  • pressure : real
  • previousX : real
  • previousY : real
  • sceneX : real
  • sceneY : real
  • startX : real
  • startY : real
  • velocity : vector2d
  • x : real
  • y : real

例子:

qml Code 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
 

Window
{
    visible : true
    width : 
    height : 
    title : qsTr("MultiPointTouchArea")

Rectangle
    {
        width : parent.width
        height : parent.height
        MultiPointTouchArea
        {
            anchors.fill : parent
            mouseEnabled : false
            maximumTouchPoints : 
            minimumTouchPoints : 
            touchPoints : [
                TouchPoint
                {
                    id : point1
                },
                TouchPoint
                {
                    id : point2
                },
                TouchPoint
                {
                    id : point3
                }
            ]
        }

Rectangle
        {
            width : ;
            height : 
            color : "green"
            x : point1.x
            y : point1.y
        }

Rectangle
        {
            width : 
            height : 
            color : "yellow"
            x : point2.x
            y : point2.y
        }

Rectangle
        {
            width : 
            height : 
            color : "red"
            x : point3.x
            y : point3.y
        }
    }

Qt官方例子:

Touch Interaction中的

  • Multipoint Flames

  多手指触摸实现绚烂的粒子效果

  • Bear-Whack

  多手指触摸多个小熊,批量阻止小熊的降落

QML MultiPointTouchArea的更多相关文章

  1. 怎样在QML中使用multitouch

    在Qt QML中.它能够利用multitouch来做一些我们想做的事情.在今天的文章中.我们将介绍怎样使用multitouch来做一些我们想做的事. 事实上,在QML中利用多点触控是很easy的一件事 ...

  2. qt quick中qml编程语言

    Qt QML 入门 — 使用C++定义QML类型 发表于 2013 年 3 月 11 日   注册C++类 注册可实例化的类型 注册不实例化的QML类型 附带属性 注册C++类 注册可实例化的类型 如 ...

  3. 查看QML数据类型

    assist输入: QML Types A Abstract3DSeries AbstractActionInput AbstractAnimation AbstractAxis AbstractAx ...

  4. QML 从无到有 3 (自动更新)

    新的需求出来啦,需要自动更新功能,不怕程序升级了. 自动更新,QML不好写,需要c++来辅助,这里就涉及QML中调用c++功能(这里就不写了,百度一下,很多). 思路:获取版本>下载程序> ...

  5. QML 从无到有 2 (移动适配)

    随着项目深入,需要移植到安卓上,问题来了,QML安卓适配! 幸好PC端程序和手机屏幕长宽比例相似.虽然单位像素,尺寸不同,通过比例缩放,可以实现组件PC和安卓通用代码. 第一步:定义全局的转换函数(3 ...

  6. QML 从无到有 (基础)

    小公司,没办法,什么都得自己亲自来. 服务端是MVC,现在需要可PC客户端和移动APP. 考虑到网页应用有很多界面框架,可以做出很漂亮的界面来,就尝试着使用nwjs来实现,可是在使用了2天的nwjs后 ...

  7. QML杂记

    1.QML编写可视化元素,运行后程序窗口上无显示.检查电脑的显卡是否支持OpenGL,如果支持请更新显卡驱动. 2.加载图片显示QML Image: Cannot open.解决在qml.qrc右击添 ...

  8. Qml 写的弹出层控件

    QML弹出窗口组件,灯箱效果.动画效果,可拖拽 核心思路:一个mask层,一个最顶层,都用rectangle,禁止事件穿透 使用 Popup { id: popup width: 200; heigh ...

  9. Qt qml 单例模式

    Qt qml 单例模式,没什么好说的,看代码吧.单例模式很适合做全局的配置文件. [示例下载] http://download.csdn.net/detail/surfsky/8539313 [以下是 ...

随机推荐

  1. 201871010125 王玉江 《面向对象程序设计(java)》 第四周学习总结

    项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://www.cnblogs.com/wswyj/ 作业学习目 ...

  2. Anaconda 下载

    Anaconda官网:https://repo.anaconda.com/archive/清华大学镜像站:https://mirrors.tuna.tsinghua.edu.cn/anaconda/a ...

  3. 02-人脸识别-基于MTCNN,框选人脸区域-detect_face

    (本系列随笔持续更新) 这部分代码是基于参考中的链接,修改后适用于TensorFlow1.6.0版本的代码.由于TensorFlow的频繁更新,所以不一定支持后续新或者就版本,特此说明. 程序的最初版 ...

  4. JDOJ3008 圆盘染色

    JDOJ3008 圆盘染色 https://neooj.com/oldoj/problem.php?id=3008 题目描述 将一个圆盘分为N (1 <= N <= 105)个扇形,每个扇 ...

  5. org.slf4j.helpers.Log4jLoggerFactory is not on classpath. Good!

    View Javadoc 1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contrib ...

  6. inputType导致TextView不能多行显示

    今天遇到一个问题很纳闷,那就是TextView不能自动换行多行显示,因为我的印象是TextView默认是可以自动换行多行显示的,今儿个怎么就不行呢. 最终找到原因,是因为设置了inputType属性导 ...

  7. ORACLE--报错,ORA-38770

    一,问题描述 背景说明,Dg备库需要恢复到三天前,但是期间没有开闪回,临时开始,出现了这个错误.原因分析: To enable Flashback Database, you configure a ...

  8. Qt 调试信息、打印信息、输出到文本

    void debug_msg(QVariant msg) { ; QFile file("debug_msg.txt"); ) { i = ; file.open(QFile::W ...

  9. java web开发入门九(Maven使用&idea创建maven项目)基于intellig idea

    Maven 1.解决的问题 jar包的依赖和管理:版本.依赖关系等 自动构建项目 2.maven介绍 1.Maven是什么? Apache Maven是一个软件项目管理的综合工具.基于项目对象模型(P ...

  10. centos 7 安装python3 & pip3

    1.安装python3 https://www.cnblogs.com/Trees/p/7497482.html 2.解决:python ModuleNotFoundError: No module ...