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

QgsActionMenu showing some sample actions for a feature¶
Class Hierarchy¶
Base classes¶
Enums
Action types. |
Methods
Returns an expression context scope used to resolve underlying actions. |
|
Returns |
|
Returns menu actions |
|
Sets a |
|
Sets an expression context scope used to resolve underlying actions. |
|
Change the feature on which actions are performed |
|
Change the mode of the actions |
Signals
Emitted after actions have been reloaded. |
- class qgis.gui.QgsActionMenu[source]¶
Bases:
QMenu
- __init__(layer: QgsVectorLayer | None, feature: QgsFeature, actionScope: str | None, parent: QWidget | None = None)
Constructs a new QgsActionMenu
- Parameters:
layer (Optional[QgsVectorLayer]) – The layer that this action will be run upon.
feature (QgsFeature) – The feature that this action will be run upon. Make sure that this feature is available for the lifetime of this object.
parent (Optional[QWidget] = None) – The usual QWidget parent.
actionScope (Optional[str]) – The action scope this menu will run in
- __init__(layer: QgsVectorLayer | None, fid: int, actionScope: str | None, parent: QWidget | None = None)
Constructs a new QgsActionMenu
- Parameters:
layer (Optional[QgsVectorLayer]) – The layer that this action will be run upon.
fid (int) – The feature id of the feature for which this action will be run.
parent (Optional[QWidget] = None) – The usual QWidget parent.
actionScope (Optional[str]) – The action scope this menu will run in
- class ActionData¶
- class ActionData(action: QgsAction, featureId: int, mapLayer: QgsMapLayer | None)
- class ActionData(action: QgsMapLayerAction | None, featureId: int, mapLayer: QgsMapLayer | None)
- class ActionData(a0: QgsActionMenu.ActionData)
Bases:
object
- actionData¶
- actionType¶
- featureId¶
- mapLayer¶
- class ActionType(*values)¶
Bases:
IntEnum
Action types.
Prior to QGIS 3.30 this was available as
QgsActionMenu
.ActionTypeAdded in version 3.30.
Invalid
: InvalidMapLayerAction
: Standard actions (defined by core or plugins), corresponds toQgsMapLayerAction
class.AttributeAction
: Custom actions (manually defined in layer properties), corresponds toQgsAction
class.
- expressionContextScope(self) QgsExpressionContextScope [source]¶
Returns an expression context scope used to resolve underlying actions.
- Return type:
- isEmpty(self) bool [source]¶
Returns
True
if the menu has no valid actions.Added in version 3.30.
- Return type:
bool
Returns menu actions
Added in version 3.12.
- Return type:
List[QgsAction]
- setActionContextGenerator(self, generator: QgsMapLayerActionContextGenerator | None)[source]¶
Sets a
QgsMapLayerActionContextGenerator
to create action contexts for the menu.The
generator
object must exist for the lifetime of the menu.Added in version 3.30.
- Parameters:
generator (Optional[QgsMapLayerActionContextGenerator])
- setExpressionContextScope(self, scope: QgsExpressionContextScope)[source]¶
Sets an expression context scope used to resolve underlying actions.
- Parameters:
scope (QgsExpressionContextScope)
- setFeature(self, feature: QgsFeature)[source]¶
Change the feature on which actions are performed
- Parameters:
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)[source]¶
Change the mode of the actions
- Parameters:
mode (QgsAttributeEditorContext.Mode) – The mode of the attribute form