QgsProcessingParameterMultipleLayers class

A parameter for processing algorithms which accepts multiple map layers.

Base classes

class QgsProcessingParameterDefinition
Base class for the definition of processing parameters.

Public static functions

static auto fromScriptCode(const QString& name, const QString& description, bool isOptional, const QString& definition) -> QgsProcessingParameterMultipleLayers*
Creates a new parameter using the definition from a script code.
static auto typeName() -> QString
Returns the type name for the parameter class.

Constructors, destructors, conversion operators

QgsProcessingParameterMultipleLayers(const QString& name, const QString& description = QString(), QgsProcessing::SourceType layerType = QgsProcessing::TypeVectorAnyGeometry, const QVariant& defaultValue = QVariant(), bool optional = false)
Constructor for QgsProcessingParameterMultipleLayers.

Public functions

auto asScriptCode() const -> QString override
Returns the parameter definition encoded in a string which can be used within a Python processing script.
auto checkValueIsAcceptable(const QVariant& input, QgsProcessingContext* context = nullptr) const -> bool override
Checks whether the specified input value is acceptable for the parameter.
auto clone() const -> QgsProcessingParameterDefinition* override
Creates a clone of the parameter definition.
auto fromVariantMap(const QVariantMap& map) -> bool override
Restores this parameter to a QVariantMap.
auto layerType() const -> QgsProcessing::SourceType
Returns the layer type for layers acceptable by the parameter.
auto minimumNumberInputs() const -> int
Returns the minimum number of layers required for the parameter.
void setLayerType(QgsProcessing::SourceType type)
Sets the layer type for layers acceptable by the parameter.
void setMinimumNumberInputs(int minimum)
Sets the minimum number of layers required for the parameter.
auto toVariantMap() const -> QVariantMap override
Saves this parameter to a QVariantMap.
auto type() const -> QString override
Unique parameter type name.
auto valueAsPythonString(const QVariant& value, QgsProcessingContext& context) const -> QString override
Returns a string version of the parameter input value, which is suitable for use as an input parameter value when running an algorithm directly from a Python command.

Function documentation

bool QgsProcessingParameterMultipleLayers::checkValueIsAcceptable(const QVariant& input, QgsProcessingContext* context = nullptr) const override

Checks whether the specified input value is acceptable for the parameter.

Returns true if the value can be accepted. The optional context parameter can be specified to allow a more stringent check to be performed, capable of checking for the presence of required layers and other factors within the context.

bool QgsProcessingParameterMultipleLayers::fromVariantMap(const QVariantMap& map) override

Restores this parameter to a QVariantMap.

Subclasses should ensure that they call the base class method.

QgsProcessing::SourceType QgsProcessingParameterMultipleLayers::layerType() const

Returns the layer type for layers acceptable by the parameter.

int QgsProcessingParameterMultipleLayers::minimumNumberInputs() const

Returns the minimum number of layers required for the parameter.

If the return value is < 1 then the parameter accepts any number of layers.

void QgsProcessingParameterMultipleLayers::setLayerType(QgsProcessing::SourceType type)

Sets the layer type for layers acceptable by the parameter.

void QgsProcessingParameterMultipleLayers::setMinimumNumberInputs(int minimum)

Sets the minimum number of layers required for the parameter.

The minimum must be >= 1 if the parameter is not optional.

QVariantMap QgsProcessingParameterMultipleLayers::toVariantMap() const override

Saves this parameter to a QVariantMap.

Subclasses should ensure that they call the base class method and then extend the result with additional properties.

QString QgsProcessingParameterMultipleLayers::valueAsPythonString(const QVariant& value, QgsProcessingContext& context) const override

Returns a string version of the parameter input value, which is suitable for use as an input parameter value when running an algorithm directly from a Python command.

The returned value must be correctly escaped - e.g. string values must be wrapped in ' 's.