WheelEvent QML Type

提供有关鼠标滚轮事件的信息。更多

Import Statement: import QtQuick

属性

详细说明

鼠标的位置可通过xy 属性找到。

另请参阅 WheelHandlerMouseArea

属性文档

x : real [read-only]

y : real [read-only]

这些属性包含由车轮事件提供的位置坐标。

另请参阅 QWheelEvent::position() 。


accepted : bool

accepted 设置为true 可以防止车轮事件传播到接收项或处理程序下面的项目。

一般来说,如果项目对车轮事件做出反应,则应接受该事件,以免堆叠顺序中较低的项目也对同一事件做出反应。

另请参阅 QWheelEvent::accepted


angleDelta : point [read-only]

该属性表示滚轮旋转的相对幅度,单位为八分之一度。该属性的xy 坐标分别表示水平和垂直方向上的三角洲。

正值表示滚轮向上/向右旋转;负值表示滚轮向下/向左旋转。

大多数鼠标类型的工作步长为15 度,在这种情况下,delta 值是120 的倍数;即120 units * 1/8 = 15 degrees

另请参阅 QWheelEvent::angleDelta() 。


buttons : int [read-only]

该属性包含滚轮事件发生时按下的鼠标键。

它包含以下内容的按位组合:

另请参见 QWheelEvent::buttons()。


inverted : bool [read-only]

返回事件传递的 delta 值是否反转。

通常情况下,如果垂直滚轮的顶部远离操作手旋转,则WheelEvent 将产生正 delta 值。同样,如果滚轮顶部向左移动,水平滚轮移动将产生带有正 delta 值的QWheelEvent

不过,在某些平台上这是可以配置的,因此上述相同的操作会产生负 delta 值(但幅度相同)。例如,在 QML 组件(如不倒翁或滑块)中,无论系统设置如何,都需要使项目的移动或旋转与轮子的方向同步,这时轮子事件处理程序可以使用反转属性来决定是否否定angleDeltapixelDelta 值。

注: 许多平台不提供此类信息。在这些平台上,inverted 总是返回false

另请参阅 QWheelEvent::inverted() 。


modifiers : int [read-only]

该属性保存事件发生前的键盘修改器标志。

它包含以下按位组合

例如,在滚轮事件中对按下的 Control 键作出反应:

WheelHandler {
    onWheel: (wheel)=> {
        if (wheel.modifiers & Qt.ControlModifier) {
            adjustZoom(wheel.angleDelta.y / 120);
        }
    }
}

另请参阅 QWheelEvent::modifiers().


pixelDelta : point [read-only]

该属性以屏幕像素为单位保存延迟,适用于具有高分辨率trackpads 的平台,如 macOS。该属性的xy 坐标分别表示水平和垂直方向上的 delta 值。这些值可直接用于滚动屏幕上的内容。

对于不支持high-resolution trackpad 的平台,pixelDelta 始终为(0,0) ,应使用angleDelta 代替。

另请参阅 QWheelEvent::pixelDelta() 。


© 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.