Class: QgsMapLayerAction¶
An action which can run on map layers The class can be used in two manners: * by instantiating it and connecting to its signals to perform an action * by subclassing and reimplementing its method (only since QGIS 3.18.2)
Class Hierarchy¶
Base classes¶
Enums
alias of |
|
alias of |
Methods
Returns |
|
Layer behavior flags. |
|
Returns |
|
Define the targets of the action |
|
Returns availibity of action |
|
Triggers the action with the specified layer and feature. |
|
Triggers the action with the specified layer and list of feature. |
|
Triggers the action with the specified layer. |
Signals
Triggered when action has been run for a specific feature |
|
Triggered when action has been run for a specific feature. |
|
Triggered when action has been run for a specific list of features |
|
Triggered when action has been run for a specific list of features |
|
Triggered when action has been run for a specific layer |
|
Triggered when action has been run for a specific layer. |
- class qgis.gui.QgsMapLayerAction[source]¶
Bases:
QAction- __init__(name: str | None, parent: QObject | None, targets: Qgis.MapLayerActionTargets | Qgis.MapLayerActionTarget = Qgis.MapLayerActionTarget.AllActions, icon: QIcon = QIcon(), flags: Qgis.MapLayerActionFlags | Qgis.MapLayerActionFlag = Qgis.MapLayerActionFlags())
Creates a map layer action which can run on any layer
Note
using AllActions as a target probably does not make a lot of sense. This default action was settled for API compatibility reasons.
- Parameters:
name (Optional[str])
parent (Optional[QObject])
targets (Union[Qgis.MapLayerActionTargets, Qgis.MapLayerActionTarget] = Qgis.MapLayerActionTarget.AllActions)
icon (QIcon = QIcon())
flags (Union[Qgis.MapLayerActionFlags, Qgis.MapLayerActionFlag] = Qgis.MapLayerActionFlags())
- __init__(name: str | None, parent: QObject | None, layer: QgsMapLayer | None, targets: Qgis.MapLayerActionTargets | Qgis.MapLayerActionTarget = Qgis.MapLayerActionTarget.AllActions, icon: QIcon = QIcon(), flags: Qgis.MapLayerActionFlags | Qgis.MapLayerActionFlag = Qgis.MapLayerActionFlags())
Creates a map layer action which can run only on a specific layer
- Parameters:
name (Optional[str])
parent (Optional[QObject])
layer (Optional[QgsMapLayer])
targets (Union[Qgis.MapLayerActionTargets, Qgis.MapLayerActionTarget] = Qgis.MapLayerActionTarget.AllActions)
icon (QIcon = QIcon())
flags (Union[Qgis.MapLayerActionFlags, Qgis.MapLayerActionFlag] = Qgis.MapLayerActionFlags())
- __init__(name: str | None, parent: QObject | None, layerType: Qgis.LayerType, targets: Qgis.MapLayerActionTargets | Qgis.MapLayerActionTarget = Qgis.MapLayerActionTarget.AllActions, icon: QIcon = QIcon(), flags: Qgis.MapLayerActionFlags | Qgis.MapLayerActionFlag = Qgis.MapLayerActionFlags())
Creates a map layer action which can run on a specific type of layer
- Parameters:
name (Optional[str])
parent (Optional[QObject])
layerType (Qgis.LayerType)
targets (Union[Qgis.MapLayerActionTargets, Qgis.MapLayerActionTarget] = Qgis.MapLayerActionTarget.AllActions)
icon (QIcon = QIcon())
flags (Union[Qgis.MapLayerActionFlags, Qgis.MapLayerActionFlag] = Qgis.MapLayerActionFlags())
- Flag¶
alias of
MapLayerActionFlag
- Flags¶
alias of
MapLayerActionFlags
- Target¶
alias of
MapLayerActionTarget
- Targets¶
alias of
MapLayerActionTargets
- canRunUsingLayer(self, layer: QgsMapLayer | None) bool[source]¶
Returns
Trueif the action can run using the specified layer.Deprecated since version 3.40: Use the version with
QgsMapLayerActionContextinstead.- Parameters:
layer (Optional[QgsMapLayer])
- Return type:
bool
- canRunUsingLayer(self, layer: QgsMapLayer | None, context: QgsMapLayerActionContext) bool[source]
Returns
Trueif the action can run using the specified layer.Note
Classes which implement this should return
Falseto the deprecatedcanRunUsingLayer()method which does not accept aQgsMapLayerActionContextargument.Added in version 3.30.
- Parameters:
layer (Optional[QgsMapLayer])
context (
QgsMapLayerActionContext)
- Return type:
bool
- flags(self) Qgis.MapLayerActionFlags[source]¶
Layer behavior flags.
- Return type:
- isEnabledOnlyWhenEditable(self) bool[source]¶
Returns
Trueif the action is only enabled for layers in editable mode.- Return type:
bool
- setTargets(self, targets: Qgis.MapLayerActionTargets | Qgis.MapLayerActionTarget)[source]¶
Define the targets of the action
- Parameters:
targets (Union[Qgis.MapLayerActionTargets, Qgis.MapLayerActionTarget])
- targets(self) Qgis.MapLayerActionTargets[source]¶
Returns availibity of action
- Return type:
- triggerForFeature(self, layer: QgsMapLayer | None, feature: QgsFeature)[source]¶
Triggers the action with the specified layer and feature.
Deprecated since version 3.40: Use the version with
QgsMapLayerActionContextinstead.- Parameters:
layer (Optional[QgsMapLayer])
feature (
QgsFeature)
- triggerForFeature(self, layer: QgsMapLayer | None, feature: QgsFeature, context: QgsMapLayerActionContext)[source]
Triggers the action with the specified layer and feature.
Added in version 3.30.
- Parameters:
layer (Optional[QgsMapLayer])
feature (
QgsFeature)context (
QgsMapLayerActionContext)
- triggerForFeatures(self, layer: QgsMapLayer | None, featureList: Iterable[QgsFeature])[source]¶
Triggers the action with the specified layer and list of feature.
Deprecated since version 3.40: Use the version with
QgsMapLayerActionContextinstead.- Parameters:
layer (Optional[QgsMapLayer])
featureList (Iterable[QgsFeature])
- triggerForFeatures(self, layer: QgsMapLayer | None, featureList: Iterable[QgsFeature], context: QgsMapLayerActionContext)[source]
Triggers the action with the specified layer and list of feature.
Added in version 3.30.
- Parameters:
layer (Optional[QgsMapLayer])
featureList (Iterable[QgsFeature])
context (
QgsMapLayerActionContext)
- triggerForLayer(self, layer: QgsMapLayer | None)[source]¶
Triggers the action with the specified layer.
Deprecated since version 3.40: Use the version with
QgsMapLayerActionContextinstead.- Parameters:
layer (Optional[QgsMapLayer])
- triggerForLayer(self, layer: QgsMapLayer | None, context: QgsMapLayerActionContext)[source]
Triggers the action with the specified layer.
Added in version 3.30.
- Parameters:
layer (Optional[QgsMapLayer])
context (
QgsMapLayerActionContext)
- signal triggeredForFeature[source]¶
Triggered when action has been run for a specific feature
Deprecated since version 3.40: Use the version with
QgsMapLayerActionContextinstead.
- signal triggeredForFeatureV2(layer: QgsMapLayer, feature: QgsFeature, context: QgsMapLayerActionContext)[source]¶
Triggered when action has been run for a specific feature.
Added in version 3.30.
- Parameters:
layer (QgsMapLayer)
feature (QgsFeature)
context (QgsMapLayerActionContext)
- signal triggeredForFeatures[source]¶
Triggered when action has been run for a specific list of features
Deprecated since version 3.40: Use the version with
QgsMapLayerActionContextinstead.
- signal triggeredForFeaturesV2(layer: QgsMapLayer, featureList: List[QgsFeature], context: QgsMapLayerActionContext)[source]¶
Triggered when action has been run for a specific list of features
Added in version 3.30.
- Parameters:
layer (QgsMapLayer)
featureList (List[QgsFeature])
context (QgsMapLayerActionContext)
- signal triggeredForLayer[source]¶
Triggered when action has been run for a specific layer
Deprecated since version 3.40: Use the version with
QgsMapLayerActionContextinstead.
- signal triggeredForLayerV2(layer: QgsMapLayer, context: QgsMapLayerActionContext)[source]¶
Triggered when action has been run for a specific layer.
Added in version 3.30.
- Parameters:
layer (QgsMapLayer)
context (QgsMapLayerActionContext)