QContextMenuEvent Class

The QContextMenuEvent class contains parameters that describe a context menu event. More...

Header: #include <QContextMenuEvent>
qmake: QT += gui
Inherits: QInputEvent

Public Types

enum Reason { Mouse, Keyboard, Other }

Detailed Description

Context menu events are sent to widgets when a user performs an action associated with opening a context menu. The actions required to open context menus vary between platforms; for example, on Windows, pressing the menu button or clicking the right mouse button will cause this event to be sent.

When this event occurs it is customary to show a QMenu with a context menu, if this is relevant to the context.

Context menu events contain a special accept flag that indicates whether the receiver accepted the event. If the event handler does not accept the event then, if possible, whatever triggered the event will be handled as a regular input event.

Member Type Documentation

enum QContextMenuEvent::Reason

This enum describes the reason why the event was sent.

ConstantValueDescription
QContextMenuEvent::Mouse0The mouse caused the event to be sent. Normally this means the right mouse button was clicked, but this is platform dependent.
QContextMenuEvent::Keyboard1The keyboard caused this event to be sent. On Windows, this means the menu button was pressed.
QContextMenuEvent::Other2The event was sent by some other means (i.e. not by the mouse or keyboard).