QgsProcessingParameterFile class

An input file or folder parameter for processing algorithms.

Base classes

class QgsProcessingParameterDefinition
Base class for the definition of processing parameters.

Public types

enum Behavior { File = 0, Folder }
Parameter behavior.

Public static functions

static auto fromScriptCode(const QString& name, const QString& description, bool isOptional, const QString& definition, Behavior behavior = File) -> QgsProcessingParameterFile*
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

QgsProcessingParameterFile(const QString& name, const QString& description = QString(), Behavior behavior = File, const QString& extension = QString(), const QVariant& defaultValue = QVariant(), bool optional = false)
Constructor for QgsProcessingParameterFile.

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 behavior() const -> Behavior
Returns the parameter behavior (e.g.
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 extension() const -> QString
Returns any specified file extension for the parameter.
auto fromVariantMap(const QVariantMap& map) -> bool override
Restores this parameter to a QVariantMap.
void setBehavior(Behavior behavior)
Sets the parameter behavior (e.g.
void setExtension(const QString& extension)
Sets a file extension for the parameter.
auto toVariantMap() const -> QVariantMap override
Saves this parameter to a QVariantMap.
auto type() const -> QString override
Unique parameter type name.

Enum documentation

enum QgsProcessingParameterFile::Behavior

Parameter behavior.

Enumerators
File

Parameter is a single file.

Folder

Parameter is a folder.

Function documentation

Behavior QgsProcessingParameterFile::behavior() const

Returns the parameter behavior (e.g.

File or Folder).

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

QString QgsProcessingParameterFile::extension() const

Returns any specified file extension for the parameter.

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

Restores this parameter to a QVariantMap.

Subclasses should ensure that they call the base class method.

void QgsProcessingParameterFile::setBehavior(Behavior behavior)

Sets the parameter behavior (e.g.

File or Folder).

void QgsProcessingParameterFile::setExtension(const QString& extension)

Sets a file extension for the parameter.

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