QGraphicsSceneContextMenuEvent Class

The QGraphicsSceneContextMenuEvent class provides context menu events in the graphics view framework. More...

Header: #include <QGraphicsSceneContextMenuEvent>
qmake: QT += widgets
Since: Qt 4.2
Inherits: QGraphicsSceneEvent

Public Types

enum Reason { Mouse, Keyboard, Other }

Public Functions

virtual ~QGraphicsSceneContextMenuEvent()
Qt::KeyboardModifiers modifiers() const
QPointF pos() const
QGraphicsSceneContextMenuEvent::Reason reason() const
QPointF scenePos() const
QPoint screenPos() const

Additional Inherited Members

  • 1 property inherited from QEvent
  • 1 public variable inherited from QEvent
  • 1 static public member inherited from QEvent
  • 2 protected variables inherited from QEvent

Detailed Description

The QGraphicsSceneContextMenuEvent class provides context menu events in the graphics view framework.

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

[virtual] QGraphicsSceneContextMenuEvent::~QGraphicsSceneContextMenuEvent()

Destroys the event.

Qt::KeyboardModifiers QGraphicsSceneContextMenuEvent::modifiers() const

Returns the keyboard modifiers in use when the context menu was requested.

QPointF QGraphicsSceneContextMenuEvent::pos() const

Returns the position of the mouse cursor in item coordinates at the moment the context menu was requested.

See also scenePos() and screenPos().

QGraphicsSceneContextMenuEvent::Reason QGraphicsSceneContextMenuEvent::reason() const

Returns the reason for the context menu event.

See also 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 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 pos() and scenePos().

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support