QGraphicsSceneEvent Class
The QGraphicsSceneEvent class provides a base class for all graphics view related events. \since
4.2 \ingroup
graphicsview-api \inmodule
QtWidgets. More...
Header: | #include <QGraphicsSceneEvent> |
Inherits: | QEvent |
Inherited By: | QGraphicsSceneContextMenuEvent, QGraphicsSceneDragDropEvent, QGraphicsSceneHelpEvent, QGraphicsSceneHoverEvent, QGraphicsSceneMouseEvent, QGraphicsSceneMoveEvent, QGraphicsSceneResizeEvent, and QGraphicsSceneWheelEvent |
Public Functions
QGraphicsSceneEvent(Type type) | |
virtual | ~QGraphicsSceneEvent() |
void | setTimestamp(quint64 ts) |
void | setWidget(QWidget *widget) |
quint64 | timestamp() const |
QWidget * | widget() const |
Protected Functions
QGraphicsSceneEvent(QGraphicsSceneEventPrivate &dd, Type type = None) |
Detailed Description
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 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 (see screenPos(), scenePos(), and 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()).
See also QEvent.
Member Function Documentation
[explicit]
QGraphicsSceneEvent::QGraphicsSceneEvent(Type type)
\internal
Constructs a generic graphics scene event of the specified type.
[protected]
QGraphicsSceneEvent::QGraphicsSceneEvent(QGraphicsSceneEventPrivate &dd, Type type = None)
\internal
Constructs a generic graphics scene event.
[virtual noexcept]
QGraphicsSceneEvent::~QGraphicsSceneEvent()
Destroys the event.
void QGraphicsSceneEvent::setTimestamp(quint64 ts)
\internal
Sets the timestamp for the event to ts.
See also timestamp().
void QGraphicsSceneEvent::setWidget(QWidget *widget)
\internal
Sets the widget related to this event.
See also widget().
quint64 QGraphicsSceneEvent::timestamp() const
\since
6.2
Returns the timestamp of the original event, or 0 if the original event does not report a time stamp.
See also setTimestamp().
QWidget *QGraphicsSceneEvent::widget() const
Returns the widget where the event originated, or nullptr
if the event originates from another application.
See also setWidget().