QGraphicsSceneEvent Class Reference

[ QtGui module]

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

继承 QEvent .

Inherited by QGraphicsSceneContextMenuEvent , QGraphicsSceneDragDropEvent , QGraphicsSceneHelpEvent , QGraphicsSceneHoverEvent , QGraphicsSceneMouseEvent , QGraphicsSceneMoveEvent , QGraphicsSceneResizeEvent and QGraphicsSceneWheelEvent .

方法


详细描述

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

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 项。

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 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 (见 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() , and lastPos() ).


方法文档编制

QGraphicsSceneEvent.setWidget ( self , QWidget   widget )

QWidget QGraphicsSceneEvent.widget ( self )

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