QGraphicsSceneEvent¶
The
QGraphicsSceneEvent
class provides a base class for all graphics view related events. More…
Inherited by: QGraphicsSceneContextMenuEvent, QGraphicsSceneDragDropEvent, QGraphicsSceneHelpEvent, QGraphicsSceneHoverEvent, QGraphicsSceneMouseEvent, QGraphicsSceneMoveEvent, QGraphicsSceneResizeEvent, QGraphicsSceneWheelEvent
Synopsis¶
Functions¶
def
widget
()
Detailed Description¶
When a
QGraphicsView
receives Qt mouse, keyboard, and drag and drop events (QMouseEvent
,QKeyEvent
, QDragEvent, etc.), it translates them into instances ofQGraphicsSceneEvent
subclasses and forwards them to theQGraphicsScene
it displays. The scene then forwards the events to the relevant items.For example, when a
QGraphicsView
receives aQMouseEvent
of type MousePress as a response to a user click, the view sends aQGraphicsSceneMouseEvent
of typeGraphicsSceneMousePress
to the underlyingQGraphicsScene
through itsmousePressEvent()
function. The defaultmousePressEvent()
implementation determines which item was clicked and forwards the event tomousePressEvent()
.Subclasses such as
QGraphicsSceneMouseEvent
andQGraphicsSceneContextMenuEvent
provide the coordinates from the originalQEvent
in screen, scene, and item coordinates (seescreenPos()
,scenePos()
, andpos()
). The item coordinates are set by theQGraphicsScene
before 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()
, andlastPos()
).See also
QEvent
- class PySide2.QtWidgets.QGraphicsSceneEvent(type)¶
- param type:
Constructs a generic graphics scene event of the specified
type
.
- PySide2.QtWidgets.QGraphicsSceneEvent.widget()¶
- Return type:
Returns the widget where the event originated, or
None
if the event originates from another application.
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.