![]() |
Qt 6.x
The Qt SDK
|
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework. More...
#include <qgraphicssceneevent.h>
Public Member Functions | |
QGraphicsSceneMouseEvent (Type type=None) | |
~QGraphicsSceneMouseEvent () | |
Destroys the event. | |
QPointF | pos () const |
Returns the mouse cursor position in item coordinates. | |
void | setPos (const QPointF &pos) |
QPointF | scenePos () const |
Returns the mouse cursor position in scene coordinates. | |
void | setScenePos (const QPointF &pos) |
QPoint | screenPos () const |
Returns the mouse cursor position in screen coordinates. | |
void | setScreenPos (const QPoint &pos) |
QPointF | buttonDownPos (Qt::MouseButton button) const |
Returns the mouse cursor position in item coordinates where the specified button was clicked. | |
void | setButtonDownPos (Qt::MouseButton button, const QPointF &pos) |
QPointF | buttonDownScenePos (Qt::MouseButton button) const |
Returns the mouse cursor position in scene coordinates where the specified button was clicked. | |
void | setButtonDownScenePos (Qt::MouseButton button, const QPointF &pos) |
QPoint | buttonDownScreenPos (Qt::MouseButton button) const |
Returns the mouse cursor position in screen coordinates where the specified button was clicked. | |
void | setButtonDownScreenPos (Qt::MouseButton button, const QPoint &pos) |
QPointF | lastPos () const |
Returns the last recorded mouse cursor position in item coordinates. | |
void | setLastPos (const QPointF &pos) |
QPointF | lastScenePos () const |
Returns the last recorded mouse cursor position in scene coordinates. | |
void | setLastScenePos (const QPointF &pos) |
QPoint | lastScreenPos () const |
Returns the last recorded mouse cursor position in screen coordinates. | |
void | setLastScreenPos (const QPoint &pos) |
Qt::MouseButtons | buttons () const |
Returns the combination of mouse buttons that were pressed at the time the event was sent. | |
void | setButtons (Qt::MouseButtons buttons) |
Qt::MouseButton | button () const |
Returns the mouse button (if any) that caused the event. | |
void | setButton (Qt::MouseButton button) |
Qt::KeyboardModifiers | modifiers () const |
Returns the keyboard modifiers in use at the time the event was sent. | |
void | setModifiers (Qt::KeyboardModifiers modifiers) |
Qt::MouseEventSource | source () const |
void | setSource (Qt::MouseEventSource source) |
Qt::MouseEventFlags | flags () const |
void | setFlags (Qt::MouseEventFlags) |
![]() | |
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. | |
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
\inmodule QtWidgets
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 \l{QGraphicsView::}{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().
Definition at line 46 of file qgraphicssceneevent.h.
Constructs a generic graphics scene mouse event of the specified type.
Definition at line 356 of file qgraphicssceneevent.cpp.
QGraphicsSceneMouseEvent::~QGraphicsSceneMouseEvent | ( | ) |
Destroys the event.
Definition at line 364 of file qgraphicssceneevent.cpp.
Qt::MouseButton QGraphicsSceneMouseEvent::button | ( | ) | const |
Returns the mouse button (if any) that caused the event.
Definition at line 584 of file qgraphicssceneevent.cpp.
References d.
Referenced by buttonDownPos(), buttonDownScenePos(), buttonDownScreenPos(), copyMouseEvent(), QGraphicsScenePrivate::mousePressEventHandler(), operator<<(), QWidgetTextControl::processEvent(), QFlickGestureRecognizer::recognize(), QGraphicsScenePrivate::sendMouseEvent(), setButton(), setButtonDownPos(), setButtonDownScenePos(), and setButtonDownScreenPos().
QPointF QGraphicsSceneMouseEvent::buttonDownPos | ( | Qt::MouseButton | button | ) | const |
Returns the mouse cursor position in item coordinates where the specified button was clicked.
Definition at line 434 of file qgraphicssceneevent.cpp.
Referenced by QGraphicsScenePrivate::mousePressEventHandler(), and QGraphicsItemPrivate::remapItemPos().
QPointF QGraphicsSceneMouseEvent::buttonDownScenePos | ( | Qt::MouseButton | button | ) | const |
Returns the mouse cursor position in scene coordinates where the specified button was clicked.
Definition at line 455 of file qgraphicssceneevent.cpp.
Referenced by QGraphicsScenePrivate::mousePressEventHandler().
QPoint QGraphicsSceneMouseEvent::buttonDownScreenPos | ( | Qt::MouseButton | button | ) | const |
Returns the mouse cursor position in screen coordinates where the specified button was clicked.
Definition at line 476 of file qgraphicssceneevent.cpp.
Referenced by QGraphicsScenePrivate::mousePressEventHandler().
Qt::MouseButtons QGraphicsSceneMouseEvent::buttons | ( | ) | const |
Returns the combination of mouse buttons that were pressed at the time the event was sent.
Definition at line 564 of file qgraphicssceneevent.cpp.
References d.
Referenced by copyMouseEvent(), QGraphicsScene::mouseMoveEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QGraphicsScenePrivate::mousePressEventHandler(), QGraphicsScene::mouseReleaseEvent(), QGraphicsView::mouseReleaseEvent(), operator<<(), QWidgetTextControl::processEvent(), QFlickGestureRecognizer::recognize(), QGraphicsItemPrivate::remapItemPos(), QGraphicsScenePrivate::sendMouseEvent(), and setButtons().
Qt::MouseEventFlags QGraphicsSceneMouseEvent::flags | ( | ) | const |
Returns the mouse event flags.
The mouse event flags provide additional information about a mouse event.
Definition at line 649 of file qgraphicssceneevent.cpp.
References d.
Referenced by operator<<(), and setFlags().
QPointF QGraphicsSceneMouseEvent::lastPos | ( | ) | const |
Returns the last recorded mouse cursor position in item coordinates.
Definition at line 497 of file qgraphicssceneevent.cpp.
References d.
Referenced by _q_hoverFromMouseEvent().
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.
Definition at line 520 of file qgraphicssceneevent.cpp.
References d.
Referenced by _q_hoverFromMouseEvent(), and QGraphicsScenePrivate::sendMouseEvent().
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.
Definition at line 543 of file qgraphicssceneevent.cpp.
References d.
Referenced by _q_hoverFromMouseEvent().
Qt::KeyboardModifiers QGraphicsSceneMouseEvent::modifiers | ( | ) | const |
Returns the keyboard modifiers in use at the time the event was sent.
Definition at line 605 of file qgraphicssceneevent.cpp.
References d.
Referenced by _q_hoverFromMouseEvent(), copyMouseEvent(), QGraphicsScenePrivate::mousePressEventHandler(), operator<<(), QWidgetTextControl::processEvent(), QFlickGestureRecognizer::recognize(), and setModifiers().
QPointF QGraphicsSceneMouseEvent::pos | ( | ) | const |
Returns the mouse cursor position in item coordinates.
Definition at line 373 of file qgraphicssceneevent.cpp.
References d.
Referenced by _q_hoverFromMouseEvent(), QWidgetTextControl::processEvent(), QGraphicsItemPrivate::remapItemPos(), setButtonDownPos(), setButtonDownScenePos(), setButtonDownScreenPos(), setLastPos(), setLastScenePos(), setLastScreenPos(), setPos(), setScenePos(), and setScreenPos().
QPointF QGraphicsSceneMouseEvent::scenePos | ( | ) | const |
Returns the mouse cursor position in scene coordinates.
Definition at line 393 of file qgraphicssceneevent.cpp.
References d.
Referenced by _q_hoverFromMouseEvent(), QGraphicsScene::event(), QGraphicsViewPrivate::mouseMoveEventHandler(), QGraphicsScenePrivate::mousePressEventHandler(), QFlickGestureRecognizer::recognize(), and QGraphicsScenePrivate::sendMouseEvent().
QPoint QGraphicsSceneMouseEvent::screenPos | ( | ) | const |
Returns the mouse cursor position in screen coordinates.
Definition at line 413 of file qgraphicssceneevent.cpp.
References d.
Referenced by _q_hoverFromMouseEvent(), copyMouseEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QGraphicsScenePrivate::mousePressEventHandler(), QWidgetTextControl::processEvent(), QTapAndHoldGestureRecognizer::recognize(), QFlickGestureRecognizer::recognize(), and QGraphicsScenePrivate::sendMouseEvent().
void QGraphicsSceneMouseEvent::setButton | ( | Qt::MouseButton | button | ) |
Definition at line 593 of file qgraphicssceneevent.cpp.
Referenced by QGraphicsView::mouseDoubleClickEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QGraphicsView::mousePressEvent(), QGraphicsView::mouseReleaseEvent(), and QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent().
void QGraphicsSceneMouseEvent::setButtonDownPos | ( | Qt::MouseButton | button, |
const QPointF & | pos | ||
) |
Definition at line 443 of file qgraphicssceneevent.cpp.
References button(), d, and pos().
Referenced by QGraphicsItemPrivate::remapItemPos(), and QGraphicsScenePrivate::sendMouseEvent().
void QGraphicsSceneMouseEvent::setButtonDownScenePos | ( | Qt::MouseButton | button, |
const QPointF & | pos | ||
) |
Definition at line 464 of file qgraphicssceneevent.cpp.
References button(), d, and pos().
Referenced by QGraphicsView::mouseDoubleClickEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QGraphicsView::mousePressEvent(), QGraphicsView::mouseReleaseEvent(), and QGraphicsScenePrivate::sendMouseEvent().
void QGraphicsSceneMouseEvent::setButtonDownScreenPos | ( | Qt::MouseButton | button, |
const QPoint & | pos | ||
) |
Definition at line 485 of file qgraphicssceneevent.cpp.
References button(), d, and pos().
Referenced by QGraphicsView::mouseDoubleClickEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QGraphicsView::mousePressEvent(), QGraphicsView::mouseReleaseEvent(), and QGraphicsScenePrivate::sendMouseEvent().
void QGraphicsSceneMouseEvent::setButtons | ( | Qt::MouseButtons | buttons | ) |
Definition at line 573 of file qgraphicssceneevent.cpp.
Referenced by QGraphicsView::mouseDoubleClickEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QGraphicsView::mousePressEvent(), QGraphicsView::mouseReleaseEvent(), and QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent().
void QGraphicsSceneMouseEvent::setFlags | ( | Qt::MouseEventFlags | flags | ) |
Definition at line 659 of file qgraphicssceneevent.cpp.
Referenced by QGraphicsView::mouseDoubleClickEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QGraphicsView::mousePressEvent(), and QGraphicsView::mouseReleaseEvent().
Definition at line 506 of file qgraphicssceneevent.cpp.
Referenced by QGraphicsItemPrivate::remapItemPos(), and QGraphicsScenePrivate::sendMouseEvent().
Definition at line 529 of file qgraphicssceneevent.cpp.
Referenced by QGraphicsView::mouseDoubleClickEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QGraphicsView::mousePressEvent(), and QGraphicsView::mouseReleaseEvent().
Definition at line 552 of file qgraphicssceneevent.cpp.
Referenced by QGraphicsView::mouseDoubleClickEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QGraphicsView::mousePressEvent(), and QGraphicsView::mouseReleaseEvent().
void QGraphicsSceneMouseEvent::setModifiers | ( | Qt::KeyboardModifiers | modifiers | ) |
Definition at line 668 of file qgraphicssceneevent.cpp.
References d, and modifiers().
Referenced by QGraphicsView::mouseDoubleClickEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QGraphicsView::mousePressEvent(), QGraphicsView::mouseReleaseEvent(), and QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent().
Definition at line 382 of file qgraphicssceneevent.cpp.
Referenced by QGraphicsItemPrivate::remapItemPos(), QGraphicsScenePrivate::sendMouseEvent(), and QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent().
Definition at line 402 of file qgraphicssceneevent.cpp.
Referenced by QGraphicsView::mouseDoubleClickEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QGraphicsView::mousePressEvent(), and QGraphicsView::mouseReleaseEvent().
Definition at line 422 of file qgraphicssceneevent.cpp.
Referenced by QGraphicsView::mouseDoubleClickEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QGraphicsView::mousePressEvent(), QGraphicsView::mouseReleaseEvent(), and QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent().
void QGraphicsSceneMouseEvent::setSource | ( | Qt::MouseEventSource | source | ) |
Definition at line 633 of file qgraphicssceneevent.cpp.
Referenced by QGraphicsView::mouseDoubleClickEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QGraphicsView::mousePressEvent(), and QGraphicsView::mouseReleaseEvent().
Qt::MouseEventSource QGraphicsSceneMouseEvent::source | ( | ) | const |
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.
Definition at line 623 of file qgraphicssceneevent.cpp.
References d.
Referenced by copyMouseEvent(), operator<<(), and setSource().