QgsProcessingParameterField class

A vector layer or feature source field parameter for processing algorithms.

Base classes

class QgsProcessingParameterDefinition
Base class for the definition of processing parameters.

Public types

enum DataType { Any = -1, Numeric = 0, String = 1, DateTime = 2 }
Field data types.

Public static functions

static auto fromScriptCode(const QString& name, const QString& description, bool isOptional, const QString& definition) -> QgsProcessingParameterField*
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

QgsProcessingParameterField(const QString& name, const QString& description = QString(), const QVariant& defaultValue = QVariant(), const QString& parentLayerParameterName = QString(), DataType type = Any, bool allowMultiple = false, bool optional = false)
Constructor for QgsProcessingParameterField.

Public functions

auto allowMultiple() const -> bool
Returns whether multiple field selections are permitted.
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 dataType() const -> DataType
Returns the acceptable data type for the field.
auto dependsOnOtherParameters() const -> QStringList override
Returns a list of other parameter names on which this parameter is dependent (e.g.
auto fromVariantMap(const QVariantMap& map) -> bool override
Restores this parameter to a QVariantMap.
auto parentLayerParameterName() const -> QString
Returns the name of the parent layer parameter, or an empty string if this is not set.
void setAllowMultiple(bool allowMultiple)
Sets whether multiple field selections are permitted.
void setDataType(DataType type)
Sets the acceptable data type for the field.
void setParentLayerParameterName(const QString& parentLayerParameterName)
Sets the name of the parent layer 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.

Enum documentation

enum QgsProcessingParameterField::DataType

Field data types.

Enumerators
Any

Accepts any field.

Numeric

Accepts numeric fields.

String

Accepts string fields.

DateTime

Accepts datetime fields.

Function documentation

bool QgsProcessingParameterField::allowMultiple() const

Returns whether multiple field selections are permitted.

bool QgsProcessingParameterField::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.

DataType QgsProcessingParameterField::dataType() const

Returns the acceptable data type for the field.

QStringList QgsProcessingParameterField::dependsOnOtherParameters() const override

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

field parameters which depend on a parent layer parameter).

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

Restores this parameter to a QVariantMap.

Subclasses should ensure that they call the base class method.

QString QgsProcessingParameterField::parentLayerParameterName() const

Returns the name of the parent layer parameter, or an empty string if this is not set.

void QgsProcessingParameterField::setAllowMultiple(bool allowMultiple)

Sets whether multiple field selections are permitted.

void QgsProcessingParameterField::setDataType(DataType type)

Sets the acceptable data type for the field.

void QgsProcessingParameterField::setParentLayerParameterName(const QString& parentLayerParameterName)

Sets the name of the parent layer parameter.

Use an empty string if this is not required.

QVariantMap QgsProcessingParameterField::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 QgsProcessingParameterField::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.