![]() |
Qt 6.x
The Qt SDK
|
The QContextMenuEvent class contains parameters that describe a context menu event. More...
#include <qevent.h>
Public Member Functions | |
QContextMenuEvent (Reason reason, const QPoint &pos, const QPoint &globalPos, Qt::KeyboardModifiers modifiers=Qt::NoModifier) | |
Constructs a context menu event object with the accept parameter flag set to false. | |
int | x () const |
Returns the x position of the mouse pointer, relative to the widget that received the event. | |
int | y () const |
Returns the y position of the mouse pointer, relative to the widget that received the event. | |
int | globalX () const |
Returns the global x position of the mouse pointer at the time of the event. | |
int | globalY () const |
Returns the global y position of the mouse pointer at the time of the event. | |
const QPoint & | pos () const |
Returns the position of the mouse pointer relative to the widget that received the event. | |
const QPoint & | globalPos () const |
Returns the global position of the mouse pointer at the time of the event. | |
Reason | reason () const |
Returns the reason for this context event. | |
![]() | |
QInputEvent (Type type, const QInputDevice *m_dev, Qt::KeyboardModifiers modifiers=Qt::NoModifier) | |
const QInputDevice * | device () const |
QInputDevice::DeviceType | deviceType () const |
Returns the type of device that generated the event. | |
Qt::KeyboardModifiers | modifiers () const |
Returns the keyboard modifier flags that existed immediately before the event occurred. | |
void | setModifiers (Qt::KeyboardModifiers modifiers) |
quint64 | timestamp () const |
Returns the window system's timestamp for this event. | |
virtual void | setTimestamp (quint64 timestamp) |
![]() | |
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. | |
Protected Attributes | |
QPoint | m_pos |
QPoint | m_globalPos |
uint | m_reason: 8 |
![]() | |
const QInputDevice * | m_dev = nullptr |
quint64 | m_timeStamp = 0 |
Qt::KeyboardModifiers | m_modState = Qt::NoModifier |
quint32 | m_reserved = 0 |
![]() | |
quint16 | t |
Additional Inherited Members | |
![]() | |
static int | registerEventType (int hint=-1) noexcept |
![]() | |
QInputEvent (Type type, PointerEventTag, const QInputDevice *dev, Qt::KeyboardModifiers modifiers=Qt::NoModifier) | |
QInputEvent (Type type, SinglePointEventTag, const QInputDevice *dev, Qt::KeyboardModifiers modifiers=Qt::NoModifier) | |
![]() | |
QEvent (Type type, InputEventTag) | |
QEvent (Type type, PointerEventTag) | |
QEvent (Type type, SinglePointEventTag) | |
The QContextMenuEvent class contains parameters that describe a context menu event.
\inmodule QtGui
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.
This enum describes the reason why the event was sent.
\value Mouse The mouse caused the event to be sent. Normally this means the right mouse button was clicked, but this is platform dependent.
\value Keyboard The keyboard caused this event to be sent. On Windows, this means the menu button was pressed.
\value Other The event was sent by some other means (i.e. not by the mouse or keyboard).
Enumerator | |
---|---|
Mouse | |
Keyboard | |
Other |
QContextMenuEvent::QContextMenuEvent | ( | Reason | reason, |
const QPoint & | pos, | ||
const QPoint & | globalPos, | ||
Qt::KeyboardModifiers | modifiers = Qt::NoModifier |
||
) |
Constructs a context menu event object with the accept parameter flag set to false.
The reason parameter must be QContextMenuEvent::Mouse or QContextMenuEvent::Keyboard.
The pos parameter specifies the mouse position relative to the receiving widget. globalPos is the mouse position in absolute coordinates. The modifiers holds the keyboard modifiers.
Definition at line 1929 of file qevent.cpp.
|
inline |
Returns the global position of the mouse pointer at the time of the event.
Definition at line 611 of file qevent.h.
Referenced by QLabel::contextMenuEvent(), QWidget::event(), and QWidgetTextControl::processEvent().
|
inline |
Returns the global x position of the mouse pointer at the time of the event.
|
inline |
Returns the global y position of the mouse pointer at the time of the event.
|
inline |
Returns the position of the mouse pointer relative to the widget that received the event.
Definition at line 610 of file qevent.h.
Referenced by QLabel::contextMenuEvent(), and QWidgetTextControl::processEvent().
|
inline |
Returns the reason for this context event.
Definition at line 613 of file qevent.h.
Referenced by QTextEdit::event().
|
inline |
|
inline |