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 () |
| quint64 | timestamp () const |
| QWidget * | widget () const |
當 QGraphicsView 接收 Qt 鼠標、鍵盤及拖放事件 ( QMouseEvent , QKeyEvent ,QDragEvent,等),它將它們翻譯成 QGraphicsSceneEvent 子類實例並將它們轉發給 QGraphicsScene 由它顯示。然後,場景將事件轉發給相關項。
例如,當 QGraphicsView 接收 QMouseEvent of type MousePress as a response to a user click, the view sends a QGraphicsSceneMouseEvent of type GraphicsSceneMousePress to the underlying QGraphicsScene through its mousePressEvent () function. The default QGraphicsScene::mousePressEvent () implementation determines which item was clicked and forwards the event to QGraphicsItem::mousePressEvent ().
Subclasses such as QGraphicsSceneMouseEvent and QGraphicsSceneContextMenuEvent provide the coordinates from the original QEvent in screen, scene, and item coordinates (see screenPos (), scenePos (),和 pos ()). The item coordinates are set by the QGraphicsScene before it forwards the event to the event to a QGraphicsItem . The mouse events also add the possibility to retrieve the coordinates from the last event received by the view (see lastScreenPos (), lastScenePos (),和 lastPos ()).
另請參閱 QEvent .
[虛擬]
QGraphicsSceneEvent::
~QGraphicsSceneEvent
()
銷毀事件。
[since 6.2]
quint64
QGraphicsSceneEvent::
timestamp
() const
Returns the timestamp of the original event, or 0 if the original event does not report a time stamp.
This function was introduced in Qt 6.2.
Returns the widget where the event originated, or
nullptr
if the event originates from another application.