QgsProcessingParameterDefinition class

Base class for the definition of processing parameters.

Parameter definitions encapsulate properties regarding the behavior of parameters, their acceptable ranges, defaults, etc.

Derived classes

class QgsProcessingDestinationParameter
Base class for all parameter definitions which represent file or layer destinations, e.g.
class QgsProcessingParameterAuthConfig
A string parameter for authentication configuration configuration ID values.
class QgsProcessingParameterBand
A raster band parameter for Processing algorithms.
class QgsProcessingParameterBoolean
A boolean parameter for processing algorithms.
class QgsProcessingParameterCrs
A coordinate reference system parameter for processing algorithms.
class QgsProcessingParameterEnum
An enum based parameter for processing algorithms, allowing for selection from predefined values.
class QgsProcessingParameterExpression
An expression parameter for processing algorithms.
class QgsProcessingParameterExtent
A rectangular map extent parameter for processing algorithms.
class QgsProcessingParameterFeatureSource
An input feature source (such as vector layers) parameter for processing algorithms.
class QgsProcessingParameterField
A vector layer or feature source field parameter for processing algorithms.
class QgsProcessingParameterFile
An input file or folder parameter for processing algorithms.
class QgsProcessingParameterMapLayer
A map layer parameter for processing algorithms.
class QgsProcessingParameterMatrix
A table (matrix) parameter for processing algorithms.
class QgsProcessingParameterMeshLayer
A mesh layer parameter for processing algorithms.
class QgsProcessingParameterMultipleLayers
A parameter for processing algorithms which accepts multiple map layers.
class QgsProcessingParameterNumber
A numeric parameter for processing algorithms.
class QgsProcessingParameterPoint
A point parameter for processing algorithms.
class QgsProcessingParameterRange
A numeric range parameter for processing algorithms.
class QgsProcessingParameterRasterLayer
A raster layer parameter for processing algorithms.
class QgsProcessingParameterString
A string parameter for processing algorithms.
class QgsProcessingParameterVectorLayer
A vector layer (with or without geometry) parameter for processing algorithms.

Public types

enum Flag { FlagAdvanced = 1 << 1, FlagHidden = 1 << 2, FlagOptional = 1 << 3, FlagIsModelOutput = 1 << 4 }
Parameter flags.

Constructors, destructors, conversion operators

QgsProcessingParameterDefinition(const QString& name, const QString& description = QString(), const QVariant& defaultValue = QVariant(), bool optional = false)
Constructor for QgsProcessingParameterDefinition.

Public functions

auto algorithm() const -> QgsProcessingAlgorithm*
Returns a pointer to the algorithm which owns this parameter.
auto asScriptCode() const -> QString virtual
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 virtual
Checks whether the specified input value is acceptable for the parameter.
auto clone() const -> QgsProcessingParameterDefinition* pure virtual
Creates a clone of the parameter definition.
auto defaultValue() const -> QVariant
Returns the default value for the parameter.
auto dependsOnOtherParameters() const -> QStringList virtual
Returns a list of other parameter names on which this parameter is dependent (e.g.
auto description() const -> QString
Returns the description for the parameter.
auto dynamicLayerParameterName() const -> QString
Returns the name of the parameter for a layer linked to a dynamic parameter, or an empty string if this is not set.
auto dynamicPropertyDefinition() const -> QgsPropertyDefinition
Returns the property definition for dynamic properties.
auto flags() const -> Flags
Returns any flags associated with the parameter.
auto fromVariantMap(const QVariantMap& map) -> bool virtual
Restores this parameter to a QVariantMap.
auto isDestination() const -> bool virtual
Returns true if this parameter represents a file or layer destination, e.g.
auto isDynamic() const -> bool
Returns true if the parameter supports is dynamic, and can support data-defined values (i.e.
auto metadata() const -> QVariantMap
Returns the parameter's freeform metadata.
auto metadata() -> QVariantMap&
Returns the parameter's freeform metadata.
auto name() const -> QString
Returns the name of the parameter.
auto provider() const -> QgsProcessingProvider*
Returns a pointer to the provider for the algorithm which owns this parameter.
void setDefaultValue(const QVariant& value)
Sets the default value for the parameter.
void setDescription(const QString& description)
Sets the description for the parameter.
void setDynamicLayerParameterName(const QString& name)
Sets the name for the parameter for a layer linked to a dynamic parameter, or an empty string if this is not set.
void setDynamicPropertyDefinition(const QgsPropertyDefinition& definition)
Sets the property definition for dynamic properties.
void setFlags(Flags flags)
Sets the flags associated with the parameter.
void setIsDynamic(bool dynamic)
Sets whether the parameter is dynamic, and can support data-defined values (i.e.
void setMetadata(const QVariantMap& metadata)
Sets the parameter's freeform metadata.
void setName(const QString& name)
Sets the name of the parameter.
auto toolTip() const -> QString virtual
Returns a formatted tooltip for use with the parameter, which gives helpful information like parameter description, ID, and extra content like default values (depending on parameter type).
auto toVariantMap() const -> QVariantMap virtual
Saves this parameter to a QVariantMap.
auto type() const -> QString pure virtual
Unique parameter type name.
auto valueAsPythonString(const QVariant& value, QgsProcessingContext& context) const -> QString virtual
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.

Protected variables

QgsProcessingAlgorithm* mAlgorithm
Pointer to algorithm which owns this parameter.
QVariant mDefault
Default value for parameter.
QString mDescription
Parameter description.
QString mDynamicLayerParameterName
Linked vector layer parameter name for dynamic properties.
Flags mFlags
Parameter flags.
bool mIsDynamic
True for dynamic parameters, which can have data-defined (QgsProperty) based values.
QVariantMap mMetadata
Freeform metadata for parameter. Mostly used by widget wrappers to customize their appearance and behavior.
QString mName
Parameter name.
QgsPropertyDefinition mPropertyDefinition
Data defined property definition.

Enum documentation

enum QgsProcessingParameterDefinition::Flag

Parameter flags.

Enumerators
FlagAdvanced

Parameter is an advanced parameter which should be hidden from users by default.

FlagHidden

Parameter is hidden and should not be shown to users.

FlagOptional

Parameter is optional.

FlagIsModelOutput

Destination parameter is final output. The parameter name will be used.

Function documentation

QgsProcessingAlgorithm* QgsProcessingParameterDefinition::algorithm() const

Returns a pointer to the algorithm which owns this parameter.

May be nullptr for non-owned parameters.

bool QgsProcessingParameterDefinition::checkValueIsAcceptable(const QVariant& input, QgsProcessingContext* context = nullptr) const virtual

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.

QVariant QgsProcessingParameterDefinition::defaultValue() const

Returns the default value for the parameter.

QStringList QgsProcessingParameterDefinition::dependsOnOtherParameters() const virtual

Returns a list of other parameter names on which this parameter is dependent (e.g.

field parameters which depend on a parent layer parameter).

QString QgsProcessingParameterDefinition::description() const

Returns the description for the parameter.

This is the user-visible string used to identify this parameter.

QString QgsProcessingParameterDefinition::dynamicLayerParameterName() const

Returns the name of the parameter for a layer linked to a dynamic parameter, or an empty string if this is not set.

Dynamic parameters (see isDynamic()) can have an optional vector layer parameter linked to them, which indicates which layer the fields and values will be available from when evaluating the dynamic parameter.

QgsPropertyDefinition QgsProcessingParameterDefinition::dynamicPropertyDefinition() const

Returns the property definition for dynamic properties.

Flags QgsProcessingParameterDefinition::flags() const

Returns any flags associated with the parameter.

bool QgsProcessingParameterDefinition::fromVariantMap(const QVariantMap& map) virtual

Restores this parameter to a QVariantMap.

Subclasses should ensure that they call the base class method.

bool QgsProcessingParameterDefinition::isDestination() const virtual

Returns true if this parameter represents a file or layer destination, e.g.

parameters which are used for the destination for layers output by an algorithm will return true.

bool QgsProcessingParameterDefinition::isDynamic() const

Returns true if the parameter supports is dynamic, and can support data-defined values (i.e.

QgsProperty based values).

QVariantMap QgsProcessingParameterDefinition::metadata() const

Returns the parameter's freeform metadata.

This is mostly used by parameter widget wrappers in order to customize their appearance and behavior.

QVariantMap& QgsProcessingParameterDefinition::metadata()

Returns the parameter's freeform metadata.

This is mostly used by parameter widget wrappers in order to customize their appearance and behavior.

QString QgsProcessingParameterDefinition::name() const

Returns the name of the parameter.

This is the internal identifier by which algorithms access this parameter.

QgsProcessingProvider* QgsProcessingParameterDefinition::provider() const

Returns a pointer to the provider for the algorithm which owns this parameter.

May be nullptr for non-owned parameters or algorithms.

void QgsProcessingParameterDefinition::setDefaultValue(const QVariant& value)

Sets the default value for the parameter.

Caller takes responsibility to ensure that value is a valid input for the parameter subclass.

void QgsProcessingParameterDefinition::setDescription(const QString& description)

Sets the description for the parameter.

This is the user-visible string used to identify this parameter.

void QgsProcessingParameterDefinition::setDynamicLayerParameterName(const QString& name)

Sets the name for the parameter for a layer linked to a dynamic parameter, or an empty string if this is not set.

Dynamic parameters (see isDynamic()) can have an optional vector layer parameter linked to them, which indicates which layer the fields and values will be available from when evaluating the dynamic parameter.

void QgsProcessingParameterDefinition::setDynamicPropertyDefinition(const QgsPropertyDefinition& definition)

Sets the property definition for dynamic properties.

void QgsProcessingParameterDefinition::setFlags(Flags flags)

Sets the flags associated with the parameter.

void QgsProcessingParameterDefinition::setIsDynamic(bool dynamic)

Sets whether the parameter is dynamic, and can support data-defined values (i.e.

QgsProperty based values).

void QgsProcessingParameterDefinition::setMetadata(const QVariantMap& metadata)

Sets the parameter's freeform metadata.

This is mostly used by parameter widget wrappers in order to customize their appearance and behavior.

void QgsProcessingParameterDefinition::setName(const QString& name)

Sets the name of the parameter.

This is the internal identifier by which algorithms access this parameter.

QVariantMap QgsProcessingParameterDefinition::toVariantMap() const virtual

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 QgsProcessingParameterDefinition::valueAsPythonString(const QVariant& value, QgsProcessingContext& context) const virtual

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.