Class: QgsProcessingParameterDistance

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 }
})

Added in version 3.2.

Class Hierarchy

Inheritance diagram of qgis.core.QgsProcessingParameterDistance

Base classes

QgsProcessingParameterNumber

A numeric parameter for processing algorithms.

QgsProcessingParameterDefinition

Base class for the definition of processing parameters.

class qgis.core.QgsProcessingParameterDistance[source]

Bases: QgsProcessingParameterNumber

__init__(name: str | None, description: str | None = '', defaultValue: Any = None, parentParameterName: str | None = '', optional: bool = False, minValue: float = -DBL_MAX + 1, maxValue: float = DBL_MAX)

Constructor for QgsProcessingParameterDistance.

Parameters:
  • name (Optional[str])

  • description (Optional[str] = '')

  • defaultValue (Any = None)

  • parentParameterName (Optional[str] = '')

  • optional (bool = False)

  • minValue (float = -DBL_MAX+1)

  • maxValue (float = DBL_MAX)

__init__(a0: QgsProcessingParameterDistance)
Parameters:

a0 (QgsProcessingParameterDistance)

defaultUnit(self) Qgis.DistanceUnit[source]

Returns the default distance unit for the parameter.

See also

setDefaultUnit()

Added in version 3.4.3.

Return type:

Qgis.DistanceUnit

parentParameterName(self) str[source]

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

Return type:

str

setDefaultUnit(self, unit: Qgis.DistanceUnit)[source]

Sets the default distance unit for the parameter.

See also

defaultUnit()

Added in version 3.4.3.

Parameters:

unit (Qgis.DistanceUnit)

setParentParameterName(self, parentParameterName: str | None)[source]

Sets the name of the parent layer parameter. Use an empty string if this is not required.

Parameters:

parentParameterName (Optional[str])