Table of Contents
- QContextMenuEvent
- Synopsis
- Detailed Description
PySide2.QtGui.QContextMenuEvent
PySide2.QtGui.QContextMenuEvent.Reason
PySide2.QtGui.QContextMenuEvent.globalPos()
PySide2.QtGui.QContextMenuEvent.globalX()
PySide2.QtGui.QContextMenuEvent.globalY()
PySide2.QtGui.QContextMenuEvent.pos()
PySide2.QtGui.QContextMenuEvent.reason()
PySide2.QtGui.QContextMenuEvent.x()
PySide2.QtGui.QContextMenuEvent.y()
Previous topic
Next topic
Quick search
QContextMenuEvent¶
The
QContextMenuEvent
class contains parameters that describe a context menu event. More…
Synopsis¶
Functions¶
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.
- class PySide2.QtGui.QContextMenuEvent(reason, pos)¶
PySide2.QtGui.QContextMenuEvent(reason, pos, globalPos)
PySide2.QtGui.QContextMenuEvent(reason, pos, globalPos, modifiers)
- param globalPos:
- param modifiers:
KeyboardModifiers
- param reason:
- param pos:
Constructs a context menu event object with the accept parameter flag set to false.
The
reason
parameter must beMouse
orKeyboard
.The
pos
parameter specifies the mouse position relative to the receiving widget.The
globalPos()
is initialized topos()
, which may not be appropriate. Use the other constructor to specify the global position explicitly.Constructs a context menu event object with the accept parameter flag set to false.
The
reason
parameter must beMouse
orKeyboard
.The
pos
parameter specifies the mouse position relative to the receiving widget.globalPos
is the mouse position in absolute coordinates.Constructs a context menu event object with the accept parameter flag set to false.
The
reason
parameter must beMouse
orKeyboard
.The
pos
parameter specifies the mouse position relative to the receiving widget.globalPos
is the mouse position in absolute coordinates. Themodifiers
holds the keyboard modifiers.
- PySide2.QtGui.QContextMenuEvent.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).
- PySide2.QtGui.QContextMenuEvent.globalPos()¶
- Return type:
Returns the global position of the mouse pointer at the time of the event.
- PySide2.QtGui.QContextMenuEvent.globalX()¶
- Return type:
int
Returns the global x position of the mouse pointer at the time of the event.
See also
- PySide2.QtGui.QContextMenuEvent.globalY()¶
- Return type:
int
Returns the global y position of the mouse pointer at the time of the event.
See also
- PySide2.QtGui.QContextMenuEvent.pos()¶
- Return type:
Returns the position of the mouse pointer relative to the widget that received the event.
See also
- PySide2.QtGui.QContextMenuEvent.reason()¶
- Return type:
Returns the reason for this context event.
- PySide2.QtGui.QContextMenuEvent.x()¶
- Return type:
int
Returns the x position of the mouse pointer, relative to the widget that received the event.
- PySide2.QtGui.QContextMenuEvent.y()¶
- Return type:
int
Returns the y position of the mouse pointer, relative to the widget that received the event.
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.