QgsProcessingParameterDistance class

A double numeric parameter for distance values.

Linked to a source layer or CRS parameter to determine what units the distance values are in.

The number of decimals places shown in a distance parameter's widget can be specified by setting the parameter's metadata. For example:

  • param = QgsProcessingParameterDistance( 'VAL', 'Threshold')
    # only show two decimal places in parameter's widgets, not 6:
    param.setMetadata( {'widget_wrapper':
      { 'decimals': 2 }
    })

Base classes

class QgsProcessingParameterNumber
A numeric parameter for processing algorithms.

Public static functions

static auto typeName() -> QString
Returns the type name for the parameter class.

Constructors, destructors, conversion operators

QgsProcessingParameterDistance(const QString& name, const QString& description = QString(), const QVariant& defaultValue = QVariant(), const QString& parentParameterName = QString(), bool optional = false, double minValue = std::numeric_limits<double>::lowest()+1, double maxValue = std::numeric_limits<double>::max()) explicit
Constructor for QgsProcessingParameterDistance.

Public functions

auto clone() const -> QgsProcessingParameterDistance* override
Creates a clone of the parameter definition.
auto defaultUnit() const -> QgsUnitTypes::DistanceUnit
Returns the default distance unit for the parameter.
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 parentParameterName() const -> QString
Returns the name of the parent parameter, or an empty string if this is not set.
void setDefaultUnit(QgsUnitTypes::DistanceUnit unit)
Sets the default distance unit for the parameter.
void setParentParameterName(const QString& parentParameterName)
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.

Function documentation

QgsUnitTypes::DistanceUnit QgsProcessingParameterDistance::defaultUnit() const

Returns the default distance unit for the parameter.

QStringList QgsProcessingParameterDistance::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 QgsProcessingParameterDistance::fromVariantMap(const QVariantMap& map) override

Restores this parameter to a QVariantMap.

Subclasses should ensure that they call the base class method.

QString QgsProcessingParameterDistance::parentParameterName() const

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

void QgsProcessingParameterDistance::setDefaultUnit(QgsUnitTypes::DistanceUnit unit)

Sets the default distance unit for the parameter.

void QgsProcessingParameterDistance::setParentParameterName(const QString& parentParameterName)

Sets the name of the parent layer parameter.

Use an empty string if this is not required.

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