![]() |
Qt 6.x
The Qt SDK
|
The QGraphicsSceneEvent class provides a base class for all graphics view related events. More...
#include <qgraphicssceneevent.h>
Public Member Functions | |
QGraphicsSceneEvent (Type type) | |
~QGraphicsSceneEvent () | |
Destroys the event. | |
QWidget * | widget () const |
Returns the widget where the event originated, or \nullptr if the event originates from another application. | |
void | setWidget (QWidget *widget) |
quint64 | timestamp () const |
void | setTimestamp (quint64 ts) |
![]() | |
QEvent (Type type) | |
Constructs an event object of type type. | |
virtual | ~QEvent () |
Destroys the event. | |
Type | type () const |
Returns the event type. | |
bool | spontaneous () const |
Returns true if the event originated outside the application (a system event); otherwise returns false . | |
virtual void | setAccepted (bool accepted) |
bool | isAccepted () const |
void | accept () |
Sets the accept flag of the event object, the equivalent of calling setAccepted(true). | |
void | ignore () |
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false). | |
bool | isInputEvent () const noexcept |
bool | isPointerEvent () const noexcept |
bool | isSinglePointEvent () const noexcept |
virtual QEvent * | clone () const |
Creates and returns an identical copy of this event. | |
Protected Member Functions | |
QGraphicsSceneEvent (QGraphicsSceneEventPrivate &dd, Type type=None) | |
![]() | |
QEvent (Type type, InputEventTag) | |
QEvent (Type type, PointerEventTag) | |
QEvent (Type type, SinglePointEventTag) | |
Protected Attributes | |
QScopedPointer< QGraphicsSceneEventPrivate > | d_ptr |
![]() | |
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 25 of file qgraphicssceneevent.h.
|
explicit |
Constructs a generic graphics scene event of the specified type.
Definition at line 262 of file qgraphicssceneevent.cpp.
References d_ptr, and QGraphicsSceneEventPrivate::q_ptr.
QGraphicsSceneEvent::~QGraphicsSceneEvent | ( | ) |
Destroys the event.
Definition at line 282 of file qgraphicssceneevent.cpp.
|
protected |
Constructs a generic graphics scene event.
Definition at line 273 of file qgraphicssceneevent.cpp.
References d_ptr, and QGraphicsSceneEventPrivate::q_ptr.
Sets the timestamp for the event to ts.
Definition at line 322 of file qgraphicssceneevent.cpp.
References d_ptr, and QGraphicsSceneEventPrivate::timestamp.
Referenced by QGraphicsView::contextMenuEvent(), QGraphicsView::mouseDoubleClickEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QGraphicsView::mousePressEvent(), QGraphicsView::mouseReleaseEvent(), QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(), and QGraphicsViewPrivate::storeDragDropEvent().
Sets the widget related to this event.
Definition at line 302 of file qgraphicssceneevent.cpp.
References d_ptr, QGraphicsSceneEventPrivate::widget, and widget().
Referenced by _q_hoverFromMouseEvent(), QGraphicsScenePrivate::cloneDragDropEvent(), QGraphicsView::contextMenuEvent(), QGraphicsScenePrivate::leaveScene(), QGraphicsView::mouseDoubleClickEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QGraphicsView::mousePressEvent(), QGraphicsView::mouseReleaseEvent(), QGraphicsViewPrivate::populateSceneDragDropEvent(), QGraphicsViewPrivate::storeDragDropEvent(), and QGraphicsView::viewportEvent().
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 313 of file qgraphicssceneevent.cpp.
References d_ptr, and QGraphicsSceneEventPrivate::timestamp.
Referenced by copyMouseEvent().
QWidget * QGraphicsSceneEvent::widget | ( | ) | const |
Returns the widget where the event originated, or \nullptr if the event originates from another application.
Definition at line 290 of file qgraphicssceneevent.cpp.
References d_ptr, and QGraphicsSceneEventPrivate::widget.
Referenced by _q_hoverFromMouseEvent(), QGraphicsScenePrivate::dispatchHoverEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QGraphicsScenePrivate::mousePressEventHandler(), QWidgetTextControl::processEvent(), QGraphicsScenePrivate::sendDragDropEvent(), QGraphicsScenePrivate::sendHoverEvent(), QGraphicsScenePrivate::sendMouseEvent(), and setWidget().
|
protected |
Definition at line 39 of file qgraphicssceneevent.h.
Referenced by QGraphicsSceneEvent(), QGraphicsSceneEvent(), setTimestamp(), setWidget(), timestamp(), and widget().