QGraphicsSceneMouseEvent Class

The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework. \since 4.2 \ingroup graphicsview-api \inmodule QtWidgets. More...

Header: #include <QGraphicsSceneMouseEvent>
Inherits: QGraphicsSceneEvent

Public Functions

QGraphicsSceneMouseEvent(Type type = None)
virtual ~QGraphicsSceneMouseEvent()
Qt::MouseButton button() const
QPointF buttonDownPos(Qt::MouseButton button) const
QPointF buttonDownScenePos(Qt::MouseButton button) const
QPoint buttonDownScreenPos(Qt::MouseButton button) const
Qt::MouseButtons buttons() const
Qt::MouseEventFlags flags() const
QPointF lastPos() const
QPointF lastScenePos() const
QPoint lastScreenPos() const
Qt::KeyboardModifiers modifiers() const
QPointF pos() const
QPointF scenePos() const
QPoint screenPos() const
void setButton(Qt::MouseButton button)
void setButtonDownPos(Qt::MouseButton button, const QPointF &pos)
void setButtonDownScenePos(Qt::MouseButton button, const QPointF &pos)
void setButtonDownScreenPos(Qt::MouseButton button, const QPoint &pos)
void setButtons(Qt::MouseButtons buttons)
void setFlags(Qt::MouseEventFlags flags)
void setLastPos(const QPointF &pos)
void setLastScenePos(const QPointF &pos)
void setLastScreenPos(const QPoint &pos)
void setModifiers(Qt::KeyboardModifiers modifiers)
void setPos(const QPointF &pos)
void setScenePos(const QPointF &pos)
void setScreenPos(const QPoint &pos)
void setSource(Qt::MouseEventSource source)
Qt::MouseEventSource source() const

Detailed Description

When a QGraphicsView receives a QMouseEvent, it translates it to a QGraphicsSceneMouseEvent. The event is then forwarded to the QGraphicsScene associated with the view. If the event is not handled by the scene, the view may use it, e.g., for the DragMode.

In addition to containing the item, scene, and screen coordinates of the event (as pos(), scenePos(), and screenPos()), mouse events also contain the coordinates of the previous mouse event received by the view. These can be retrieved with lastPos(), lastScreenPos(), and lastScenePos().

See also QGraphicsSceneContextMenuEvent, QGraphicsSceneHoverEvent, QGraphicsSceneWheelEvent, and QMouseEvent.

Member Function Documentation

[explicit] QGraphicsSceneMouseEvent::QGraphicsSceneMouseEvent(Type type = None)

\internal

Constructs a generic graphics scene mouse event of the specified type.

[virtual noexcept] QGraphicsSceneMouseEvent::~QGraphicsSceneMouseEvent()

Destroys the event.

Qt::MouseButton QGraphicsSceneMouseEvent::button() const

Returns the mouse button (if any) that caused the event.

See also setButton(), buttons(), and modifiers().

QPointF QGraphicsSceneMouseEvent::buttonDownPos(Qt::MouseButton button) const

Returns the mouse cursor position in item coordinates where the specified button was clicked.

See also setButtonDownPos(), buttonDownScenePos(), buttonDownScreenPos(), and pos().

QPointF QGraphicsSceneMouseEvent::buttonDownScenePos(Qt::MouseButton button) const

Returns the mouse cursor position in scene coordinates where the specified button was clicked.

See also setButtonDownScenePos(), buttonDownPos(), buttonDownScreenPos(), and scenePos().

QPoint QGraphicsSceneMouseEvent::buttonDownScreenPos(Qt::MouseButton button) const

Returns the mouse cursor position in screen coordinates where the specified button was clicked.

See also setButtonDownScreenPos(), screenPos(), buttonDownPos(), and buttonDownScenePos().

Qt::MouseButtons QGraphicsSceneMouseEvent::buttons() const

Returns the combination of mouse buttons that were pressed at the time the event was sent.

See also setButtons(), button(), and modifiers().

Qt::MouseEventFlags QGraphicsSceneMouseEvent::flags() const

\since5.4

Returns the mouse event flags.

The mouse event flags provide additional information about a mouse event.

See also setFlags(), Qt::MouseEventFlag, and QMouseEvent::flags().

QPointF QGraphicsSceneMouseEvent::lastPos() const

Returns the last recorded mouse cursor position in item coordinates.

See also setLastPos(), lastScenePos(), lastScreenPos(), and pos().

QPointF QGraphicsSceneMouseEvent::lastScenePos() const

Returns the last recorded mouse cursor position in scene coordinates. The last recorded position is the position of the previous mouse event received by the view that created the event.

See also setLastScenePos(), lastPos(), lastScreenPos(), and scenePos().

QPoint QGraphicsSceneMouseEvent::lastScreenPos() const

Returns the last recorded mouse cursor position in screen coordinates. The last recorded position is the position of the previous mouse event received by the view that created the event.

See also setLastScreenPos(), lastPos(), lastScenePos(), and screenPos().

Qt::KeyboardModifiers QGraphicsSceneMouseEvent::modifiers() const

Returns the keyboard modifiers in use at the time the event was sent.

See also setModifiers(), buttons(), and button().

QPointF QGraphicsSceneMouseEvent::pos() const

Returns the mouse cursor position in item coordinates.

See also setPos(), scenePos(), screenPos(), and lastPos().

QPointF QGraphicsSceneMouseEvent::scenePos() const

Returns the mouse cursor position in scene coordinates.

See also setScenePos(), pos(), screenPos(), and lastScenePos().

QPoint QGraphicsSceneMouseEvent::screenPos() const

Returns the mouse cursor position in screen coordinates.

See also setScreenPos(), pos(), scenePos(), and lastScreenPos().

void QGraphicsSceneMouseEvent::setButton(Qt::MouseButton button)

\internal

See also button().

void QGraphicsSceneMouseEvent::setButtonDownPos(Qt::MouseButton button, const QPointF &pos)

\internal

See also buttonDownPos().

void QGraphicsSceneMouseEvent::setButtonDownScenePos(Qt::MouseButton button, const QPointF &pos)

\internal

See also buttonDownScenePos().

void QGraphicsSceneMouseEvent::setButtonDownScreenPos(Qt::MouseButton button, const QPoint &pos)

\internal

See also buttonDownScreenPos().

void QGraphicsSceneMouseEvent::setButtons(Qt::MouseButtons buttons)

\internal

See also buttons().

void QGraphicsSceneMouseEvent::setFlags(Qt::MouseEventFlags flags)

\since5.4 \internal

See also flags().

void QGraphicsSceneMouseEvent::setLastPos(const QPointF &pos)

\internal

See also lastPos().

void QGraphicsSceneMouseEvent::setLastScenePos(const QPointF &pos)

\internal

See also lastScenePos().

void QGraphicsSceneMouseEvent::setLastScreenPos(const QPoint &pos)

\internal

See also lastScreenPos().

void QGraphicsSceneMouseEvent::setModifiers(Qt::KeyboardModifiers modifiers)

\internal

See also modifiers().

void QGraphicsSceneMouseEvent::setPos(const QPointF &pos)

\internal

See also pos().

void QGraphicsSceneMouseEvent::setScenePos(const QPointF &pos)

\internal

See also scenePos().

void QGraphicsSceneMouseEvent::setScreenPos(const QPoint &pos)

\internal

See also screenPos().

void QGraphicsSceneMouseEvent::setSource(Qt::MouseEventSource source)

\since5.4 \internal

See also source().

Qt::MouseEventSource QGraphicsSceneMouseEvent::source() const

\since5.4

Returns information about the mouse event source.

The mouse event source can be used to distinguish between genuine and artificial mouse events. The latter are events that are synthesized from touch events by the operating system or Qt itself.

See also setSource(), Qt::MouseEventSource, and QMouseEvent::source().