QgsMapLayerAction class

An action which can run on map layers.

Public types

enum Flag { EnabledOnlyWhenEditable = 1 << 1 }
Flags which control action behavior /since QGIS 3.0.

Constructors, destructors, conversion operators

QgsMapLayerAction(const QString& name, QObject* parent, Targets targets = AllActions, const QIcon& icon = QIcon(), QgsMapLayerAction::Flags flags = nullptr)
Action behavior flags.
QgsMapLayerAction(const QString& name, QObject* parent, QgsMapLayer* layer, Targets targets = AllActions, const QIcon& icon = QIcon(), QgsMapLayerAction::Flags flags = nullptr)
Creates a map layer action which can run only on a specific layer.
QgsMapLayerAction(const QString& name, QObject* parent, QgsMapLayer::LayerType layerType, Targets targets = AllActions, const QIcon& icon = QIcon(), QgsMapLayerAction::Flags flags = nullptr)
Creates a map layer action which can run on a specific type of layer.

Public functions

auto canRunUsingLayer(QgsMapLayer* layer) const -> bool
True if action can run using the specified layer.
auto flags() const -> QgsMapLayerAction::Flags
Layer behavior flags.
auto isEnabledOnlyWhenEditable() const -> bool
Returns true if the action is only enabled for layers in editable mode.
void setTargets(Targets targets)
Define the targets of the action.
auto targets() const -> const Targets&
Returns availibity of action.
void triggerForFeature(QgsMapLayer* layer, const QgsFeature* feature)
Triggers the action with the specified layer and feature.
void triggerForFeatures(QgsMapLayer* layer, const QList<QgsFeature>& featureList)
Triggers the action with the specified layer and list of feature.
void triggerForLayer(QgsMapLayer* layer)
Triggers the action with the specified layer.

Signals

void triggeredForFeature(QgsMapLayer* layer, const QgsFeature& feature)
Triggered when action has been run for a specific feature.
void triggeredForFeatures(QgsMapLayer* layer, const QList<QgsFeature>& featureList)
Triggered when action has been run for a specific list of features.
void triggeredForLayer(QgsMapLayer* layer)
Triggered when action has been run for a specific layer.

Enum documentation

enum QgsMapLayerAction::Flag

Flags which control action behavior /since QGIS 3.0.

Enumerators
EnabledOnlyWhenEditable

Action should be shown only for editable layers.

Function documentation

QgsMapLayerAction::QgsMapLayerAction(const QString& name, QObject* parent, Targets targets = AllActions, const QIcon& icon = QIcon(), QgsMapLayerAction::Flags flags = nullptr)

Action behavior flags.

QgsMapLayerAction::Flags QgsMapLayerAction::flags() const

Layer behavior flags.

bool QgsMapLayerAction::isEnabledOnlyWhenEditable() const

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