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. JS高阶---作用域面试

    面试题1: ,答案为10 有一点需要明确:作用域是在定义编写代码时已经决定好的 面试题2: 结果1: 结果2: 首先在内部作用域找,没有 然后在全局作用域找,window没有,所以会报错 如果想找对象 ...

  2. LOJ 510: 「LibreOJ NOI Round #1」北校门外的回忆

    题目传送门:LOJ #510. 题意简述: 给出一个在 \(K\) 进制下的树状数组,但是它的实现有问题. 形式化地说,令 \(\mathrm{lowbit}(x)\) 为在 \(K\) 进制下的 \ ...

  3. 基于VLC库C#开发可播放摄像头及任意格式视频的播放器

    前言 本文主要讲述,在WPF中,借助Vlc.DotNet调用VLC类库,实现视频播功能,下面我们先来做开发前的准备工作. 准备工作 首先,我们创建一个项目WpfVLC,然后,进入Neget搜索Vlc. ...

  4. 用python提取xml里面的链接源码

    因群里朋友需要提取xml地图里面的链接,就写了这个程序. 代码: #coding=utf-8 import urllib import urllib.request import re url='ht ...

  5. loadrunner 添加检查点

    1.首先使用录制的方式,把论坛的代码编写完成后,要判断的执行前插入检查点,使用右键方式,弹出的下拉的菜单中进行选择“insert”的选项. 2.就在弹出下一级的菜单中,进行选中一个为“new step ...

  6. (day46)DOM、BOM、事件

    目录 一.BOM (一)定义 (二)window对象 (三)window的子对象 (1)navigator对象 (2)screen对象 (3)history对象 (4)location对象 (5)弹出 ...

  7. springboot配置spring security 静态资源不能访问

    在springboot整合spring security 过程中曾遇到下面问题:(spring boot 2.0以上版本   spring security 5.x    (spring  secur ...

  8. 跑批 - Spring Batch 批处理使用记录

    根据spring官网文档提供的spring batch的demo进行小的测验 启动类与原springboot启动类无异 package com.example.batchprocessing; imp ...

  9. 11/9 <Stack> 155 232 225

    155. Min Stack class MinStack { int min = Integer.MAX_VALUE; Stack<Integer> stack = new Stack& ...

  10. [LeetCode] 104. Maximum Depth of Binary Tree 二叉树的最大深度

    Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...