Class: QgsActionMenu¶
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¶
- 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:
IntEnumAction 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 toQgsMapLayerActionclass.AttributeAction: Custom actions (manually defined in layer properties), corresponds toQgsActionclass.
- expressionContextScope(self) QgsExpressionContextScope[source]¶
Returns an expression context scope used to resolve underlying actions.
- Return type:
- isEmpty(self) bool[source]¶
Returns
Trueif the menu has no valid actions.Added in version 3.30.
- Return type:
bool
- signal messageDiscarded[source]¶
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.
- signal messageEmitted[source]¶
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.
- signal reinit[source]¶
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.
- setActionContextGenerator(self, generator: QgsMapLayerActionContextGenerator | None)[source]¶
Sets a
QgsMapLayerActionContextGeneratorto create action contexts for the menu.The
generatorobject 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