QtBase
v6.3.1
|
The QGraphicsSceneEvent class provides a base class for all graphics view related events. More...
#include <qgraphicssceneevent.h>
Public Member Functions | |
QGraphicsSceneEvent (Type type) | |
~QGraphicsSceneEvent () | |
QWidget * | widget () const |
void | setWidget (QWidget *widget) |
quint64 | timestamp () const |
void | setTimestamp (quint64 ts) |
Public Member Functions inherited from QEvent | |
QEvent (Type type) | |
virtual | ~QEvent () |
Type | type () const |
bool | spontaneous () const |
virtual void | setAccepted (bool accepted) |
bool | isAccepted () const |
void | accept () |
void | ignore () |
bool | isInputEvent () const noexcept |
bool | isPointerEvent () const noexcept |
bool | isSinglePointEvent () const noexcept |
virtual QEvent * | clone () const |
Protected Member Functions | |
QGraphicsSceneEvent (QGraphicsSceneEventPrivate &dd, Type type=None) | |
Protected Member Functions inherited from QEvent | |
QEvent (Type type, InputEventTag) | |
QEvent (Type type, PointerEventTag) | |
QEvent (Type type, SinglePointEventTag) | |
Protected Attributes | |
QScopedPointer< QGraphicsSceneEventPrivate > | d_ptr |
Protected Attributes inherited from QEvent | |
quint16 | t |
The QGraphicsSceneEvent class provides a base class for all graphics view related events.
\inmodule QtWidgets
When a 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 receives a 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 \l{QGraphicsScene::}{mousePressEvent()} function. The default QGraphicsScene::mousePressEvent() implementation determines which item was clicked and forwards the event to QGraphicsItem::mousePressEvent().
\omit ### Beskrive widget() \endomit
Subclasses such as QGraphicsSceneMouseEvent and QGraphicsSceneContextMenuEvent provide the coordinates from the original QEvent in screen, scene, and item coordinates (see \l{QGraphicsSceneMouseEvent::}{screenPos()}, \l{QGraphicsSceneMouseEvent::}{scenePos()}, and \l{QGraphicsSceneMouseEvent::}{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 \l{QGraphicsSceneMouseEvent::}{lastScreenPos()}, \l{QGraphicsSceneMouseEvent::}{lastScenePos()}, and \l{QGraphicsSceneMouseEvent::}{lastPos()}).
Definition at line 61 of file qgraphicssceneevent.h.
|
explicit |
Definition at line 298 of file qgraphicssceneevent.cpp.
QGraphicsSceneEvent::~QGraphicsSceneEvent | ( | ) |
Destroys the event.
Definition at line 318 of file qgraphicssceneevent.cpp.
|
protected |
Definition at line 309 of file qgraphicssceneevent.cpp.
Definition at line 338 of file qgraphicssceneevent.cpp.
quint64 QGraphicsSceneEvent::timestamp | ( | ) | const |
Returns the timestamp of the original event, or 0 if the original event does not report a time stamp.
Definition at line 349 of file qgraphicssceneevent.cpp.
QWidget * QGraphicsSceneEvent::widget | ( | ) | const |
Returns the widget where the event originated, or \nullptr if the event originates from another application.
Definition at line 326 of file qgraphicssceneevent.cpp.
|
protected |
Definition at line 75 of file qgraphicssceneevent.h.