class QContextMenuEvent#

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

Inheritance diagram of PySide6.QtGui.QContextMenuEvent

Synopsis#

Methods#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

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.

class Reason#

This enum describes the reason why the event was sent.

Constant

Description

QContextMenuEvent.Mouse

The mouse caused the event to be sent. Normally this means the right mouse button was clicked, but this is platform dependent.

QContextMenuEvent.Keyboard

The keyboard caused this event to be sent. On Windows, this means the menu button was pressed.

QContextMenuEvent.Other

The event was sent by some other means (i.e. not by the mouse or keyboard).

__init__(reason, pos)#
Parameters:

Note

This function is deprecated.

Use the other constructor instead (global position is required).

Constructs a context menu event object with the accept parameter flag set to false.

The reason parameter must be Mouse or Keyboard .

The pos parameter specifies the mouse position relative to the receiving widget.

The globalPos() is initialized to pos() , which may not be appropriate. Use the other constructor to specify the global position explicitly.

__init__(reason, pos, globalPos[, modifiers=Qt.NoModifier])
Parameters:

Constructs a context menu event object with the accept parameter flag set to false.

The reason parameter must be Mouse or 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.

__init__(arg__1)
Parameters:

arg__1QContextMenuEvent

globalPos()#
Return type:

QPoint

Returns the global position of the mouse pointer at the time of the event.

See also

x() y() pos()

globalX()#
Return type:

int

Returns the global x position of the mouse pointer at the time of the event.

globalY()#
Return type:

int

Returns the global y position of the mouse pointer at the time of the event.

pos()#
Return type:

QPoint

Returns the position of the mouse pointer relative to the widget that received the event.

See also

x() y() globalPos()

reason()#
Return type:

Reason

Returns the reason for this context event.

x()#
Return type:

int

Returns the x position of the mouse pointer, relative to the widget that received the event.

See also

y() pos()

y()#
Return type:

int

Returns the y position of the mouse pointer, relative to the widget that received the event.

See also

x() pos()