QNativeGestureEvent Class
QNativeGestureEvent 类包含描述手势事件的参数。更多
头文件: | #include <QNativeGestureEvent> |
CMake.QNativeGestureEvent | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
继承: | QSinglePointEvent |
- 所有成员(包括继承成员)的列表
- 已废弃成员
- QNativeGestureEvent 属于事件类。
公共函数
(since 6.2) | QNativeGestureEvent(Qt::NativeGestureType type, const QPointingDevice *device, int fingerCount, const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos, qreal value, const QPointF &delta, quint64 sequenceId = UINT64_MAX) |
(since 6.2) QPointF | delta() const |
(since 6.2) int | fingerCount() const |
Qt::NativeGestureType | gestureType() const |
qreal | value() const |
详细说明
本地手势事件由操作系统生成,通常是通过解释触控板触摸事件。手势事件是高级事件,如缩放、旋转或平移。有几种类型持有增量值:即value() 和delta() 提供了从上一个事件到当前事件的差值。
事件类型 | 说明 | 触摸序列 |
---|---|---|
Qt::ZoomNativeGesture | 以百分比为单位的放大倍率差。 | macOS 和 Wayland:双指捏合。 |
Qt::SmartZoomNativeGesture | 布尔放大状态。 | macOS:双指双击(触控板)/单指双击(魔术鼠标)。 |
Qt::RotateNativeGesture | 旋转三角洲(单位:度 | macOS 和 Wayland:双指旋转。 |
Qt::SwipeNativeGesture | 轻扫角度,单位为度。 | macOS:可在触控板设置中配置。 |
Qt::PanNativeGesture | 位移三角,单位为像素。 | Wayland:三根或更多手指作为一组向任意方向移动。 |
此外,手势事件流前后还会发送 BeginNativeGesture 和 EndNativeGesture:
BeginNativeGesture ZoomNativeGesture ZoomNativeGesture ZoomNativeGesture EndNativeGesture
事件流可能包括不同类型的交错手势:例如,双指捏合手势会产生缩放和旋转事件流,根据平台的不同,PanNativeGesture 有时会与这些事件交错。
其他类型则是独立事件:SmartZoomNativeGesture 和 SwipeNativeGesture 只在每次检测到手势时发生一次。
注: 在触摸板上,以两个手指为一组移动(双指轻弹手势)通常用于滚动;在这种情况下,Qt 会生成 QWheelEvents。这就是需要三个或更多手指才能生成 PanNativeGesture 的原因。
另请参阅 Qt::NativeGestureType,QGestureEvent, 和QWheelEvent 。
成员函数文档
[since 6.2]
QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QPointingDevice *device, int fingerCount, const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos, qreal value, const QPointF &delta, quint64 sequenceId = UINT64_MAX)
构建一个type 类型的本地手势事件,该事件源于device ,描述了fingerCount 手指参与的scenePos 手势。
点localPos 、scenePos 和globalPos 分别指定手势相对于接收部件或项目、窗口、屏幕或桌面的位置。
value 的解释取决于手势:对于旋转原生手势(RotateNativeGesture)或轻扫原生手势(SwipeNativeGesture),它是一个角度(单位:度)。对于 ZoomNativeGesture(缩放原生手势), 是一个增量缩放因子,通常远小于 1,表示目标项目应按如下方式调整缩放比例: item.scale = item.scale * (1 + event.value)value
对于 PanNativeGesture,delta 给出了视口、部件或项目应移动或平移的距离(以像素为单位)。
此函数在 Qt 6.2 中引入。
[since 6.2]
QPointF QNativeGestureEvent::delta() const
返回自上次事件后移动的距离(以像素为单位)。平移手势以像素为单位提供目标部件、项目或视口内容的移动距离。
此函数在 Qt 6.2 中引入。
另请参阅 QPanGesture::delta().
[since 6.2]
int QNativeGestureEvent::fingerCount() const
如果已知,返回参与手势的手指数量。当gestureType() 为Qt::BeginNativeGesture 或Qt::EndNativeGesture 时,这一信息往往是未知的,因此 fingerCount() 返回0
。
该函数在 Qt 6.2 中引入。
Qt::NativeGestureType QNativeGestureEvent::gestureType() const
返回手势类型。
qreal QNativeGestureEvent::value() const
返回手势值。该值应根据手势类型进行解释。例如,缩放手势提供的是缩放系数 delta,而旋转手势提供的是旋转系数 delta。
另请参阅 QNativeGestureEvent 和gestureType()。
© 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.