QGraphicsSceneContextMenuEvent Class
QGraphicsSceneContextMenuEvent 类提供图形视图框架中的上下文菜单事件。更多
Header: | #include <QGraphicsSceneContextMenuEvent> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
qmake: | QT += widgets |
继承: | QGraphicsSceneEvent |
公共类型
enum | Reason { Mouse, Keyboard, Other } |
公共函数
virtual | ~QGraphicsSceneContextMenuEvent() |
Qt::KeyboardModifiers | modifiers() const |
QPointF | pos() const |
QGraphicsSceneContextMenuEvent::Reason | reason() const |
QPointF | scenePos() const |
QPoint | screenPos() const |
详细说明
由QGraphicsView 接收的QContextMenuEvent 会被转换为 QGraphicsSceneContextMenuEvent。QContextMenuEvent::globalPos() 被转换为项目、场景和屏幕坐标(pos(),scenePos(), 和screenPos() )。
另请参阅 QGraphicsSceneMouseEvent,QGraphicsSceneWheelEvent, 和QContextMenuEvent 。
成员类型文档
enum QGraphicsSceneContextMenuEvent::Reason
该枚举描述了发送上下文事件的原因。
常量 | 值 | 说明 |
---|---|---|
QGraphicsSceneContextMenuEvent::Mouse | 0 | 鼠标导致事件被发送。在大多数平台上,这意味着鼠标右键被点击。 |
QGraphicsSceneContextMenuEvent::Keyboard | 1 | 键盘触发了该事件。在 Windows 和 macOS 上,这表示按下了菜单键。 |
QGraphicsSceneContextMenuEvent::Other | 2 | 事件是通过其他方式发送的(即不是通过鼠标或键盘)。 |
成员函数文档
[virtual noexcept]
QGraphicsSceneContextMenuEvent::~QGraphicsSceneContextMenuEvent()
摧毁事件。
Qt::KeyboardModifiers QGraphicsSceneContextMenuEvent::modifiers() const
返回请求上下文菜单时使用的键盘修改器。
QPointF QGraphicsSceneContextMenuEvent::pos() const
返回请求上下文菜单时鼠标光标在项目坐标中的位置。
QGraphicsSceneContextMenuEvent::Reason QGraphicsSceneContextMenuEvent::reason() const
返回上下文菜单事件的原因。
另请参阅 QGraphicsSceneContextMenuEvent::Reason 。
QPointF QGraphicsSceneContextMenuEvent::scenePos() const
返回请求上下文菜单时鼠标光标在场景坐标中的位置。
QPoint QGraphicsSceneContextMenuEvent::screenPos() const
返回请求上下文菜单时鼠标光标在屏幕坐标中的位置。
© 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.