内容表

上一话题

QGraphicsSceneDragDropEvent

下一话题

QGraphicsSceneHelpEvent

QGraphicsSceneEvent

QGraphicsSceneEvent class provides a base class for all graphics view related events. 更多

Inheritance diagram of PySide2.QtWidgets.QGraphicsSceneEvent

继承者: QGraphicsSceneContextMenuEvent , QGraphicsSceneDragDropEvent , QGraphicsSceneHelpEvent , QGraphicsSceneHoverEvent , QGraphicsSceneMouseEvent , QGraphicsSceneMoveEvent , QGraphicsSceneResizeEvent , QGraphicsSceneWheelEvent

概要

函数

详细描述

QGraphicsView receives Qt mouse, keyboard, and drag and drop events ( QMouseEvent , QKeyEvent , QDragEvent, etc.), it translates them into instances of QGraphicsSceneEvent subclasses and forwards them to the QGraphicsScene it displays. The scene then forwards the events to the relevant items.

For example, when a 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 mousePressEvent() implementation determines which item was clicked and forwards the event to 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

class QGraphicsSceneEvent ( type )
param type

Type

Constructs a generic graphics scene event of the specified type .

PySide2.QtWidgets.QGraphicsSceneEvent. widget ( )
返回类型

QWidget

Returns the widget where the event originated, or None if the event originates from another application.