QGraphicsSceneEventclass provides a base class for all graphics view related events. 更多 …
继承者: QGraphicsSceneContextMenuEvent , QGraphicsSceneDragDropEvent , QGraphicsSceneHelpEvent , QGraphicsSceneHoverEvent , QGraphicsSceneMouseEvent , QGraphicsSceneMoveEvent , QGraphicsSceneResizeEvent , QGraphicsSceneWheelEvent
当
QGraphicsViewreceives Qt mouse, keyboard, and drag and drop events (QMouseEvent,QKeyEvent, QDragEvent, etc.), it translates them into instances ofQGraphicsSceneEventsubclasses and forwards them to theQGraphicsSceneit displays. The scene then forwards the events to the relevant items.For example, when a
QGraphicsView接收QMouseEventof type MousePress as a response to a user click, the view sends aQGraphicsSceneMouseEventof typeGraphicsSceneMousePressto the underlyingQGraphicsScenethrough itsmousePressEvent()function. The defaultmousePressEvent()implementation determines which item was clicked and forwards the event tomousePressEvent().Subclasses such as
QGraphicsSceneMouseEventandQGraphicsSceneContextMenuEventprovide the coordinates from the originalQEventin screen, scene, and item coordinates (seescreenPos(),scenePos(),和pos()). The item coordinates are set by theQGraphicsScenebefore it forwards the event to the event to aQGraphicsItem. The mouse events also add the possibility to retrieve the coordinates from the last event received by the view (seelastScreenPos(),lastScenePos(),和lastPos()).另请参阅
QGraphicsSceneEvent
(
type
)
¶
- param type
Type
Constructs a generic graphics scene event of the specified
type
.