本页内容

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

受保护函数

QSinglePointEvent(QSinglePointEvent &&)
QSinglePointEvent &operator=(QSinglePointEvent &&)
QSinglePointEvent &operator=(const QSinglePointEvent &other)

详细说明

属性文档

exclusivePointGrabber : QObject*

该属性保存将接收未来更新的对象

独占抓取器是一个已选择接收所有未来更新事件以及包含与该事件相同坐标的释放事件的对象。

设置 exclusivePointGrabber 属性是一种便捷操作,等同于:

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

访问函数:

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

成员函数文档

[protected delete] QSinglePointEvent::QSinglePointEvent(QSinglePointEvent &&)

通过移动构造一个QSinglePointEvent 实例。该函数已被删除。

Qt::MouseButton QSinglePointEvent::button() const

返回触发该事件的按钮。

对于鼠标移动事件,以及TabletMove 、TabletEnterProximity 和TabletLeaveProximity 事件,返回值始终为Qt::NoButton 。

另请参阅 buttons()。

Qt::MouseButtons QSinglePointEvent::buttons() const

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

按钮状态是通过“或”运算符将Qt::LeftButton 、Qt::RightButton 和Qt::MiddleButton 组合而成的。

对于鼠标移动或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 。

[protected delete] QSinglePointEvent &QSinglePointEvent::operator=(QSinglePointEvent &&)

将other 按“移动赋值”方式赋值给此QSinglePointEvent 实例。该函数已被删除。

[noexcept protected default] QSinglePointEvent &QSinglePointEvent::operator=(const QSinglePointEvent &other)

将other 复制并赋值给此QSinglePointEvent 实例。

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