QGraphicsSceneMouseEvent Class
QGraphicsSceneMouseEvent 类在图形视图框架中提供了鼠标事件。更多内容...
| 头文件: | #include <QGraphicsSceneMouseEvent> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
| qmake: | QT += widgets |
| 继承自: | QGraphicsSceneEvent |
公共函数
| virtual | ~QGraphicsSceneMouseEvent() |
| Qt::MouseButton | button() const |
| QPointF | buttonDownPos(Qt::MouseButton button) const |
| QPointF | buttonDownScenePos(Qt::MouseButton button) const |
| QPoint | buttonDownScreenPos(Qt::MouseButton button) const |
| Qt::MouseButtons | buttons() const |
| Qt::MouseEventFlags | flags() const |
| QPointF | lastPos() const |
| QPointF | lastScenePos() const |
| QPoint | lastScreenPos() const |
| Qt::KeyboardModifiers | modifiers() const |
| QPointF | pos() const |
| QPointF | scenePos() const |
| QPoint | screenPos() const |
| Qt::MouseEventSource | source() const |
详细说明
当QGraphicsView 接收到QMouseEvent 时,会将其转换为QGraphicsSceneMouseEvent。随后,该事件会被转发至与视图关联的QGraphicsScene 。如果该事件未被场景处理,视图可以使用它,例如用于DragMode 。
除了包含事件的项、场景和屏幕坐标(分别由pos()、scenePos() 和screenPos() 提供)外,鼠标事件还包含视图接收到的上一个鼠标事件的坐标。这些坐标可通过lastPos()、lastScreenPos() 和lastScenePos() 获取。
另请参阅 QGraphicsSceneContextMenuEvent 、QGraphicsSceneHoverEvent 、QGraphicsSceneWheelEvent 以及QMouseEvent 。
成员函数文档
[virtual noexcept] QGraphicsSceneMouseEvent::~QGraphicsSceneMouseEvent()
销毁该事件。
Qt::MouseButton QGraphicsSceneMouseEvent::button() const
返回触发该事件的鼠标按钮(如有)。
QPointF QGraphicsSceneMouseEvent::buttonDownPos(Qt::MouseButton button) const
返回在指定button 被点击时的鼠标光标位置(以项目坐标系为基准)。
另请参阅 buttonDownScenePos()、buttonDownScreenPos() 和pos()。
QPointF QGraphicsSceneMouseEvent::buttonDownScenePos(Qt::MouseButton button) const
返回在场景坐标系中,指定button 被点击时的鼠标光标位置。
另请参阅 buttonDownPos()、buttonDownScreenPos() 和scenePos()。
QPoint QGraphicsSceneMouseEvent::buttonDownScreenPos(Qt::MouseButton button) const
返回指定button 被点击时鼠标光标在屏幕坐标系中的位置。
另请参阅 screenPos()、buttonDownPos() 和buttonDownScenePos()。
Qt::MouseButtons QGraphicsSceneMouseEvent::buttons() const
返回事件发送时被按下的鼠标按钮组合。
Qt::MouseEventFlags QGraphicsSceneMouseEvent::flags() const
返回鼠标事件标志。
鼠标事件标志提供了有关鼠标事件的额外信息。
另请参阅 Qt::MouseEventFlag 和QMouseEvent::flags()。
QPointF QGraphicsSceneMouseEvent::lastPos() const
返回以项目坐标系表示的最后记录的鼠标光标位置。
另请参阅 lastScenePos()、lastScreenPos() 以及pos()。
QPointF QGraphicsSceneMouseEvent::lastScenePos() const
返回以场景坐标系表示的最后记录的鼠标光标位置。最后记录的位置是指创建该事件的视图所接收到的上一次鼠标事件的位置。
另请参阅 lastPos()、lastScreenPos() 和scenePos()。
QPoint QGraphicsSceneMouseEvent::lastScreenPos() const
返回最后记录的鼠标光标位置(以屏幕坐标表示)。最后记录的位置是指创建该事件的视图所接收的上一次鼠标事件的位置。
另请参阅 lastPos()、lastScenePos() 和screenPos()。
Qt::KeyboardModifiers QGraphicsSceneMouseEvent::modifiers() const
返回事件发送时正在使用的键盘修饰键。
QPointF QGraphicsSceneMouseEvent::pos() const
返回鼠标光标在项目坐标系中的位置。
另请参阅 scenePos()、screenPos() 和lastPos()。
QPointF QGraphicsSceneMouseEvent::scenePos() const
返回场景坐标系中的鼠标光标位置。
另请参阅 pos()、screenPos() 和lastScenePos()。
QPoint QGraphicsSceneMouseEvent::screenPos() const
返回鼠标光标在屏幕坐标系中的位置。
另请参阅 pos()、scenePos() 和lastScreenPos()。
Qt::MouseEventSource QGraphicsSceneMouseEvent::source() const
返回有关鼠标事件源的信息。
鼠标事件源可用于区分真实的鼠标事件与人工生成的鼠标事件。后者是指由操作系统或 Qt 自身根据触摸事件合成的事件。
另请参阅 Qt::MouseEventSource 和QMouseEvent::source()。
© 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.