Class: QgsActionMenu

class qgis.gui.QgsActionMenu

Bases: PyQt5.QtWidgets.QMenu

This class is a menu that is populated automatically with the actions defined for a given layer.

QgsActionMenu(layer: QgsVectorLayer, feature: QgsFeature, actionScope: str, parent: QWidget = None) Constructs a new QgsActionMenu

  • layer – The layer that this action will be run upon.

  • feature – The feature that this action will be run upon. Make sure that this feature is available for the lifetime of this object.

  • parent – The usual QWidget parent.

  • actionScope – The action scope this menu will run in

QgsActionMenu(layer: QgsVectorLayer, fid: int, actionScope: str, parent: QWidget = None) Constructs a new QgsActionMenu

class ActionData

Bases: sip.wrapper

Constructor for ActionData.

QgsActionMenu.ActionData(action: QgsAction, featureId: int, mapLayer: QgsMapLayer)

QgsActionMenu.ActionData(action: QgsMapLayerAction, featureId: int, mapLayer: QgsMapLayer)


class ActionType(value)

Bases: enum.IntEnum

Action types.

Prior to QGIS 3.30 this was available as QgsActionMenu.ActionType

New in version 3.30.

  • Invalid: Invalid

  • MapLayerAction: Standard actions (defined by core or plugins), corresponds to QgsMapLayerAction class.

  • AttributeAction: Custom actions (manually defined in layer properties), corresponds to QgsAction class.


alias of Qgis

actionEvent(self, QActionEvent)
changeEvent(self, QEvent)
childEvent(self, QChildEvent)
closeEvent(self, QCloseEvent)
columnCount(self) int
connectNotify(self, QMetaMethod)
contextMenuEvent(self, QContextMenuEvent)
create(self, window: PyQt5.sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)
customEvent(self, QEvent)
destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)
disconnectNotify(self, QMetaMethod)
dragEnterEvent(self, QDragEnterEvent)
dragLeaveEvent(self, QDragLeaveEvent)
dragMoveEvent(self, QDragMoveEvent)
dropEvent(self, QDropEvent)
enterEvent(self, QEvent)
event(self, QEvent) bool
expressionContextScope(self) QgsExpressionContextScope

Returns an expression context scope used to resolve underlying actions.

New in version 3.0.

Return type


focusInEvent(self, QFocusEvent)
focusNextChild(self) bool
focusNextPrevChild(self, bool) bool
focusOutEvent(self, QFocusEvent)
focusPreviousChild(self) bool
hideEvent(self, QHideEvent)
initPainter(self, QPainter)
initStyleOption(self, QStyleOptionMenuItem, QAction)
inputMethodEvent(self, QInputMethodEvent)
isEmpty(self) bool

Returns True if the menu has no valid actions.

New in version 3.30.

Return type


isSignalConnected(self, QMetaMethod) bool
keyPressEvent(self, QKeyEvent)
keyReleaseEvent(self, QKeyEvent)
leaveEvent(self, QEvent)
menuActions(self) List[QgsAction]

Returns menu actions

New in version 3.12.

Return type


metric(self, QPaintDevice.PaintDeviceMetric) int
mouseDoubleClickEvent(self, QMouseEvent)
mouseMoveEvent(self, QMouseEvent)
mousePressEvent(self, QMouseEvent)
mouseReleaseEvent(self, QMouseEvent)
moveEvent(self, QMoveEvent)
nativeEvent(self, Union[QByteArray, bytes, bytearray], PyQt5.sip.voidptr) Tuple[bool, int]
paintEvent(self, QPaintEvent)
receivers(self, PYQT_SIGNAL) int

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type


resizeEvent(self, QResizeEvent)
sender(self) QObject
senderSignalIndex(self) int
setActionContextGenerator(self, generator: QgsMapLayerActionContextGenerator)

Sets a QgsMapLayerActionContextGenerator to create action contexts for the menu.

The generator object must exist for the lifetime of the menu.

New in version 3.30.


generator (QgsMapLayerActionContextGenerator) –

setExpressionContextScope(self, scope: QgsExpressionContextScope)

Sets an expression context scope used to resolve underlying actions.

New in version 3.0.


scope (QgsExpressionContextScope) –

setFeature(self, feature: QgsFeature)

Change the feature on which actions are performed


feature (QgsFeature) – A feature. Will not take ownership. It’s the callers responsibility to keep the feature as long as the menu is displayed and the action is running.

setMode(self, mode: QgsAttributeEditorContext.Mode)

Change the mode of the actions


mode (QgsAttributeEditorContext.Mode) – The mode of the attribute form

sharedPainter(self) QPainter
showEvent(self, QShowEvent)
tabletEvent(self, QTabletEvent)
timerEvent(self, QTimerEvent)
wheelEvent(self, QWheelEvent)