Class: QgsMapLayerAction

class qgis.gui.QgsMapLayerAction

Bases: PyQt5.QtWidgets.QAction

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)

QgsMapLayerAction(name: str, parent: QObject, targets: Union[Qgis.MapLayerActionTargets, Qgis.MapLayerActionTarget] = Qgis.MapLayerActionTarget.AllActions, icon: QIcon = QIcon(), flags: Union[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.

QgsMapLayerAction(name: str, parent: QObject, layer: QgsMapLayer, targets: Union[Qgis.MapLayerActionTargets, Qgis.MapLayerActionTarget] = Qgis.MapLayerActionTarget.AllActions, icon: QIcon = QIcon(), flags: Union[Qgis.MapLayerActionFlags, Qgis.MapLayerActionFlag] = Qgis.MapLayerActionFlags()) Creates a map layer action which can run only on a specific layer

QgsMapLayerAction(name: str, parent: QObject, layerType: Qgis.LayerType, targets: Union[Qgis.MapLayerActionTargets, Qgis.MapLayerActionTarget] = Qgis.MapLayerActionTarget.AllActions, icon: QIcon = QIcon(), flags: Union[Qgis.MapLayerActionFlags, Qgis.MapLayerActionFlag] = Qgis.MapLayerActionFlags()) Creates a map layer action which can run on a specific type of layer

Enums

Flag

alias of MapLayerActionFlag

Target

alias of MapLayerActionTarget

Methods

canRunUsingLayer

Returns True if the action can run using the specified layer.

childEvent

connectNotify

customEvent

disconnectNotify

event

flags

Layer behavior flags.

isEnabledOnlyWhenEditable

Returns True if the action is only enabled for layers in editable mode.

isSignalConnected

receivers

sender

senderSignalIndex

setTargets

Define the targets of the action

targets

Returns availibity of action

timerEvent

triggerForFeature

Triggers the action with the specified layer and feature.

triggerForFeatures

Triggers the action with the specified layer and list of feature.

triggerForLayer

Triggers the action with the specified layer.

Signals

triggeredForFeature

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

triggeredForFeatureV2

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

triggeredForFeatures

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

triggeredForFeaturesV2

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

triggeredForLayer

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

triggeredForLayerV2

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

Flag

alias of MapLayerActionFlag

Flags

alias of MapLayerActionFlags

Target

alias of MapLayerActionTarget

Targets

alias of MapLayerActionTargets

canRunUsingLayer(self, layer: QgsMapLayer) bool

Returns True if the action can run using the specified layer.

Deprecated since version use: the version with QgsMapLayerActionContext instead.

canRunUsingLayer(self, layer: QgsMapLayer, context: QgsMapLayerActionContext) -> bool Returns True if the action can run using the specified layer.

Note

Classes which implement this should return False to the deprecated canRunUsingLayer() method which does not accept a QgsMapLayerActionContext argument.

New in version 3.30.

Parameters:

layer (QgsMapLayer) –

Return type:

bool

childEvent(self, QChildEvent)
connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
disconnectNotify(self, QMetaMethod)
event(self, QEvent) bool
flags(self) Qgis.MapLayerActionFlags

Layer behavior flags.

Return type:

Qgis.MapLayerActionFlags

isEnabledOnlyWhenEditable(self) bool

Returns True if the action is only enabled for layers in editable mode.

Return type:

bool

isSignalConnected(self, QMetaMethod) bool
receivers(self, PYQT_SIGNAL) int
sender(self) QObject
senderSignalIndex(self) int
setTargets(self, targets: Qgis.MapLayerActionTargets | Qgis.MapLayerActionTarget)

Define the targets of the action

Parameters:

targets (Union[Qgis.MapLayerActionTargets) –

targets(self) Qgis.MapLayerActionTargets

Returns availibity of action

Return type:

Qgis.MapLayerActionTargets

timerEvent(self, QTimerEvent)
triggerForFeature(self, layer: QgsMapLayer, feature: QgsFeature)

Triggers the action with the specified layer and feature.

Deprecated since version use: the version with QgsMapLayerActionContext instead.

triggerForFeature(self, layer: QgsMapLayer, feature: QgsFeature, context: QgsMapLayerActionContext) Triggers the action with the specified layer and feature.

New in version 3.30.

Parameters:
triggerForFeatures(self, layer: QgsMapLayer, featureList: Iterable[QgsFeature])

Triggers the action with the specified layer and list of feature.

Deprecated since version use: the version with QgsMapLayerActionContext instead.

triggerForFeatures(self, layer: QgsMapLayer, featureList: Iterable[QgsFeature], context: QgsMapLayerActionContext) Triggers the action with the specified layer and list of feature.

New in version 3.30.

Parameters:
triggerForLayer(self, layer: QgsMapLayer)

Triggers the action with the specified layer.

Deprecated since version use: the version with QgsMapLayerActionContext instead.

triggerForLayer(self, layer: QgsMapLayer, context: QgsMapLayerActionContext) Triggers the action with the specified layer.

New in version 3.30.

Parameters:

layer (QgsMapLayer) –

triggeredForFeature

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

triggeredForFeatureV2

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

triggeredForFeatures

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

triggeredForFeaturesV2

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

triggeredForLayer

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

triggeredForLayerV2

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL