QGraphicsSceneEvent 类
QGraphicsSceneEvent 类提供了一个所有图形视图相关事件的基类。 更多...
| 头文件 | #include <QGraphicsSceneEvent> | 
| CMake | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) | 
| qmake | QT += widgets | 
| 继承自 | QEvent | 
| 被继承自 | QGraphicsSceneContextMenuEvent, QGraphicsSceneDragDropEvent, QGraphicsSceneHelpEvent, QGraphicsSceneHoverEvent, QGraphicsSceneMouseEvent, QGraphicsSceneMoveEvent, QGraphicsSceneResizeEvent, 和 QGraphicsSceneWheelEvent | 
公共函数
| virtual | ~QGraphicsSceneEvent() | 
| (自 6.2)quint64 | timestamp() const | 
| QWidget * | widget() const | 
详细说明
当 QGraphicsView 收到 Qt 鼠标、键盘和拖放事件(例如 QMouseEvent、QKeyEvent、QDragEvent 等),它将这些事件转换为 QGraphicsSceneEvent 子类实例,并将它们转发到它显示的 QGraphicsScene。该场景随后将事件转发到相关项。
例如,当 QGraphicsView 在对用户点击的一个响应中接收到 QMouseEvent 类型为 MousePress 时,视图通过它的 mousePressEvent() 函数将一个类型为 GraphicsSceneMousePress 的 QGraphicsSceneMouseEvent 转发到其下层的 QGraphicsScene。默认的 QGraphicsScene::mousePressEvent() 实现将事件转发到 QGraphicsItem::mousePressEvent。
子类例如QGraphicsSceneMouseEvent和QGraphicsSceneContextMenuEvent提供了从原始的QEvent中获取屏幕、场景和项目坐标,具体请参阅screenPos()、scenePos()和pos()().项目坐标由QGraphicsScene在将其事件传输给QGraphicsItem之前设置。鼠标事件还添加了从视图收到的最后事件中获取坐标的可能性(请参阅lastScreenPos()、lastScenePos()和lastPos()())。
另请参阅QEvent。
© 2024 Qt公司。本文档中的贡献包含的版权归其各自所有者所有。本文档是根据Free Software Foundation发布的GNU自由文档许可协议版本1.3的条款许可的。Qt及其相关标志是芬兰和/或世界其他地区的Qt公司的商标。所有其他商标均为其各自所有者的财产。