PinchArea QML Type
实现简单的捏合手势处理。更多
Import Statement: | import QtQuick |
Inherits: |
属性
- enabled : bool
- pinch
- pinch.active : bool
- pinch.dragAxis : enumeration
- pinch.maximumRotation : real
- pinch.maximumScale : real
- pinch.maximumX : real
- pinch.maximumY : real
- pinch.minimumRotation : real
- pinch.minimumScale : real
- pinch.minimumX : real
- pinch.minimumY : real
- pinch.target : Item
信号
- pinchFinished(PinchEvent pinch)
- pinchStarted(PinchEvent pinch)
- pinchUpdated(PinchEvent pinch)
- smartZoom(PinchEvent pinch)
详细说明
QtQuick 1.1 中添加了 PinchArea 类型。
PinchArea 是一种不可见项目,通常与可见项目结合使用,以便为该项目提供捏合手势处理。
enabled 属性用于启用或禁用代理项目的捏合处理。禁用时,捏合区域对鼠标/触摸事件透明。
PinchArea 有两种用法:
- 设置
pinch.target
以提供与项目的自动交互 - 使用 onPinchStarted、onPinchUpdated 和 onPinchFinished 处理程序
自 Qt 5.5 起,PinchArea 可对来自操作系统的本地捏合手势事件(如果可用)做出反应;否则,它只对触摸事件做出反应。
另请参阅 PinchEvent,QNativeGestureEvent, 和QTouchEvent 。
属性文档
enabled : bool |
该属性表示项目是否接受捏合手势。
该属性默认为 true。
pinch
提供了一种方便的方法,使项目对捏合手势做出反应。
pinch.target
指定要拖动的项目的 id。pinch.active
指定目标项目当前是否正在被拖动。pinch.minimumScale
和 限制了 Item.scale 属性的范围,但不包括 属性。pinch.maximumScale
PinchEvent
scalepinch.minimumRotation
和 限制了 Item.rotation 属性的范围,但不包括 属性。pinch.maximumRotation
PinchEvent
rotationpinch.dragAxis
指定是否不允许拖动( ),是否可以水平拖动( ),是否可以垂直拖动( ),是否可以同时拖动( )。Pinch.NoDrag
Pinch.XAxis
Pinch.YAxis
Pinch.XAndYAxis
pinch.minimum
和 限制目标可沿相应轴拖动的距离。pinch.maximum
信号文档
pinchFinished(PinchEvent pinch) |
当捏合区域检测到捏合手势已完成时,就会发出该信号。
pinch 参数(与pinch 属性不同)提供了有关捏合手势的信息,包括捏合的比例、中心和角度。
注: 相应的处理程序是onPinchFinished
。
pinchStarted(PinchEvent pinch) |
当捏合区域检测到捏合手势开始时,就会发出该信号:检测到两个触摸点(手指),并且它们的移动超过了startDragDistance 手势开始的阈值。
pinch 参数(与pinch 属性不同)提供了有关捏合手势的信息,包括捏合的比例、中心和角度。在pinchStarted
信号发出时,无论之前的手势结果如何,这些值都将重置为默认值:pinch.scale 将为1.0
,pinch.rotation 将为0.0
。随着手势的进行,pinchUpdated 将报告与这些默认值的偏差。
要忽略该手势,请将pinch.accepted
属性设为 false。手势将被取消,不会再发送任何事件。
注: 相应的处理程序是onPinchStarted
。
pinchUpdated(PinchEvent pinch) |
当捏合区域检测到捏合手势发生变化时,就会发出该信号。
pinch 参数提供了有关捏合手势的信息,包括捏合的比例、中心和角度。这些值仅反映自当前手势开始以来的变化,因此不受pinch 属性中最小和最大限制的限制。
注: 相应的处理程序是onPinchUpdated
。
smartZoom(PinchEvent pinch) |
当捏合区域检测到智能缩放手势时会发出该信号。该手势仅在某些操作系统(如 macOS)上出现。
pinch 参数提供了有关捏合手势的信息,包括手势发生的位置。当手势表示用户希望进入智能缩放时,pinch.scale
将大于 0;当退出时, 将大于 0(尽管通常使用相同的手势在两种状态之间切换)。
注: 相应的处理程序是onSmartZoom
。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.