QGraphicsSceneContextMenuEvent Class
The QGraphicsSceneContextMenuEvent class provides context menu events in the graphics view framework. \since
4.2 \ingroup
graphicsview-api \inmodule
QtWidgets. More...
Header: | #include <QGraphicsSceneContextMenuEvent> |
Inherits: | QGraphicsSceneEvent |
Public Types
enum | Reason { Mouse, Keyboard, Other } |
Public Functions
QGraphicsSceneContextMenuEvent(Type type = None) | |
virtual | ~QGraphicsSceneContextMenuEvent() |
Qt::KeyboardModifiers | modifiers() const |
QPointF | pos() const |
Reason | reason() const |
QPointF | scenePos() const |
QPoint | screenPos() const |
void | setModifiers(Qt::KeyboardModifiers modifiers) |
void | setPos(const QPointF &point) |
void | setReason(Reason reason) |
void | setScenePos(const QPointF &point) |
void | setScreenPos(const QPoint &point) |
Detailed Description
A QContextMenuEvent received by a QGraphicsView is translated into a QGraphicsSceneContextMenuEvent. The QContextMenuEvent::globalPos() is translated into item, scene, and screen coordinates (pos(), scenePos(), and screenPos()).
See also QGraphicsSceneMouseEvent, QGraphicsSceneWheelEvent, and QContextMenuEvent.
Member Type Documentation
enum QGraphicsSceneContextMenuEvent::Reason
This enum describes the reason why the context event was sent.
Constant | Value | Description |
---|---|---|
QGraphicsSceneContextMenuEvent::Mouse | 0 | The mouse caused the event to be sent. On most platforms, this means the right mouse button was clicked. |
QGraphicsSceneContextMenuEvent::Keyboard | 1 | The keyboard caused this event to be sent. On Windows and macOS, this means the menu button was pressed. |
QGraphicsSceneContextMenuEvent::Other | 2 | The event was sent by some other means (i.e. not by the mouse or keyboard). |
Member Function Documentation
[explicit]
QGraphicsSceneContextMenuEvent::QGraphicsSceneContextMenuEvent(Type type = None)
\internal
Constructs a graphics scene context menu event of the specified type.
[virtual noexcept]
QGraphicsSceneContextMenuEvent::~QGraphicsSceneContextMenuEvent()
Destroys the event.
Qt::KeyboardModifiers QGraphicsSceneContextMenuEvent::modifiers() const
Returns the keyboard modifiers in use when the context menu was requested.
See also setModifiers().
QPointF QGraphicsSceneContextMenuEvent::pos() const
Returns the position of the mouse cursor in item coordinates at the moment the context menu was requested.
See also setPos(), scenePos(), and screenPos().
Reason QGraphicsSceneContextMenuEvent::reason() const
Returns the reason for the context menu event.
See also setReason() and QGraphicsSceneContextMenuEvent::Reason.
QPointF QGraphicsSceneContextMenuEvent::scenePos() const
Returns the position of the mouse cursor in scene coordinates at the moment the context menu was requested.
See also setScenePos(), pos(), and screenPos().
QPoint QGraphicsSceneContextMenuEvent::screenPos() const
Returns the position of the mouse cursor in screen coordinates at the moment the context menu was requested.
See also setScreenPos(), pos(), and scenePos().
void QGraphicsSceneContextMenuEvent::setModifiers(Qt::KeyboardModifiers modifiers)
\internal
Sets the keyboard modifiers associated with the context menu to the modifiers specified.
See also modifiers().
void QGraphicsSceneContextMenuEvent::setPos(const QPointF &point)
\internal
Sets the position associated with the context menu to the given point in item coordinates.
See also pos().
void QGraphicsSceneContextMenuEvent::setReason(Reason reason)
\internal
Sets the reason for the context menu event to reason.
See also reason().
void QGraphicsSceneContextMenuEvent::setScenePos(const QPointF &point)
\internal
Sets the position associated with the context menu to the given point in scene coordinates.
See also scenePos().
void QGraphicsSceneContextMenuEvent::setScreenPos(const QPoint &point)
\internal
Sets the position associated with the context menu to the given point in screen coordinates.
See also screenPos().