QgsProcessingParameterString class

A string parameter for processing algorithms.

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) -> QgsProcessingParameterString*
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

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

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 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 multiLine() const -> bool
Returns true if the parameter allows multiline strings.
void setMultiLine(bool multiLine)
Sets whether the parameter allows multiline strings.
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 QgsProcessingParameterString::fromVariantMap(const QVariantMap& map) override

Restores this parameter to a QVariantMap.

Subclasses should ensure that they call the base class method.

bool QgsProcessingParameterString::multiLine() const

Returns true if the parameter allows multiline strings.

void QgsProcessingParameterString::setMultiLine(bool multiLine)

Sets whether the parameter allows multiline strings.

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