QSinglePointEvent Class

用于包含单点的指针事件(如鼠标事件)的基类。更多

头文件: #include <QSinglePointEvent>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
Qt 6.0
继承 QPointerEvent
继承于

QEnterEvent,QHoverEvent,QMouseEvent,QNativeGestureEvent,QTabletEvent, 以及QWheelEvent

属性

公共函数

Qt::MouseButton button() const
Qt::MouseButtons buttons() const
QObject *exclusivePointGrabber() const
QPointF globalPosition() const
QPointF position() const
QPointF scenePosition() const
void setExclusivePointGrabber(QObject *exclusiveGrabber)

重新实现的公共函数

virtual bool isBeginEvent() const override
virtual bool isEndEvent() const override
virtual bool isUpdateEvent() const override

详细说明

属性文档

exclusivePointGrabber : QObject*

该属性包含接收未来更新的对象

独占抓取器是选择接收所有未来更新事件和包含与此事件相同点的发布事件的对象。

设置 exclusivePointGrabber 属性可方便地等同于:

setExclusiveGrabber(points().first(), exclusiveGrabber);

访问函数:

QObject *exclusivePointGrabber() const
void setExclusivePointGrabber(QObject *exclusiveGrabber)

成员函数文档

Qt::MouseButton QSinglePointEvent::button() const

返回导致事件发生的按钮。

对于鼠标移动事件以及TabletMove,TabletEnterProximityTabletLeaveProximity 事件,返回值总是Qt::NoButton

另请参阅 buttons().

Qt::MouseButtons QSinglePointEvent::buttons() const

返回事件发生时的按钮状态。

按钮状态是Qt::LeftButtonQt::RightButtonQt::MiddleButton 的组合,使用 OR 运算符。

对于鼠标移动或TabletMove 事件,这是所有按下的按钮。

对于鼠标按下、双击或TabletPress 事件,包括引发事件的按钮。

对于鼠标释放或TabletRelease 事件,不包括导致事件发生的按钮。

另请参见 button()。

QPointF QSinglePointEvent::globalPosition() const

返回此事件中的点在屏幕或虚拟桌面上的位置。

注意: 鼠标指针的全局位置会在事件发生时记录下来。这在异步窗口系统(如 X11)中非常重要;当您根据鼠标事件移动部件时,globalPosition() 与QCursor::pos() 返回的当前光标位置可能会有很大差异。

另请参见 position()。

[override virtual] bool QSinglePointEvent::isBeginEvent() const

如果该事件代表button 被按下,则返回true

[override virtual] bool QSinglePointEvent::isEndEvent() const

如果该事件代表button 被释放,则返回true

[override virtual] bool QSinglePointEvent::isUpdateEvent() const

如果该事件不包括button state 中的更改,则返回true

QPointF QSinglePointEvent::position() const

返回该事件中点的位置,相对于接收到该事件的部件或项目。

如果要根据鼠标事件移动部件,请使用globalPosition() 代替。

另请参阅 globalPosition().

QPointF QSinglePointEvent::scenePosition() const

返回事件中点相对于窗口或场景的位置。

另请参阅 QEventPoint::scenePosition

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