zoukankan      html  css  js  c++  java
  • QML MultiPointTouchArea

    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
     
    import QtQuick 2.12
    import QtQuick.Window 2.12

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

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

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

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

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

    Qt官方例子:

    Touch Interaction中的

    • Multipoint Flames

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

    • Bear-Whack

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

  • 相关阅读:
    markdown自动生成侧边栏TOC /目录
    jquery和javascript的区别
    Jquery中AJAX参数详细(1)-转
    jQuery.ajax介绍
    人人开源分模块,非原生html报错,很难查找问题所在,有vue语法
    《SSH网上商城》-视频目录--代码可以跑起来
    《第16项目:国家税务协同平台项目》-视频目录
    项目:《ssh框架综合项目开发视频》-视频目录和第六天的EasyUI简单讲解
    项目:《JavaWeb图书管理系统视频》--代码修复还可以运行起来
    Maven项目在更新过程停止,再更新无效-->解决
  • 原文地址:https://www.cnblogs.com/MakeView660/p/11302763.html
Copyright © 2011-2022 走看看