Class: QgsProcessingModelerParameterWidget

A widget for customising the value of Processing algorithm parameter inside a Processing model.

The widget provides choice of the linked source for values for the parameter inside the model. E.g. parameters can be a static value, an evaluated expression results, the output from another child algorithm, or an input parameter for the model itself.

Individual modeler parameter widgets are not usually created directly, instead they are constructed through the central registry, via calls to QgsGui.processingGuiRegistry()->:py:func:createModelerParameterWidget() <qgis.gui.QgsProcessingModelerParameterWidget.createModelerParameterWidget>.

Added in version 3.4.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsProcessingModelerParameterWidget

Base classes

QWidget

QObject

QPaintDevice

QgsExpressionContextGenerator

Abstract interface for generating an expression context.

Methods

createLabel

Creates a label for use identifying the associated parameter.

isModelOutput

Returns True if the widget is set to the model output mode.

modelOutputName

Returns the model output name, if isModelOutput() is True.

parameterDefinition

Returns the parameter definition associated with this wrapper.

populateSources

Populates the widget with available sources for the parameter's value, e.g. adding the available child algorithm outputs and model input parameter choices.

registerProcessingContextGenerator

Registers a Processing context generator class that will be used to retrieve a Processing context for the widget when required.

setDialog

Sets the parent dialog in which the widget is shown.

setExpressionHelpText

Set the expected expression format text, which is shown in the expression builder dialog for the widget when in the "pre-calculated" expression mode.

setSourceType

Sets the current source type for the parameter.

setToModelOutput

Sets the widget to a model output, for destination parameters only.

setWidgetContext

Sets the context in which the modeler parameter widget is shown, e.g., the parent model algorithm and other relevant information which allows the widget to fine-tune its behavior.

setWidgetValue

Sets the current value for the parameter.

value

Returns the current value of the parameter.

class qgis.gui.QgsProcessingModelerParameterWidget[source]

Bases: QWidget, QgsExpressionContextGenerator

__init__(model: QgsProcessingModelAlgorithm | None, childId: str | None, parameter: QgsProcessingParameterDefinition | None, context: QgsProcessingContext, parent: QWidget | None = None)

Constructor for QgsProcessingModelerParameterWidget, for the specified parameter definition within the given model.

The ID of the child algorithm within the model must be specified via the childId argument. This value corresponds to the QgsProcessingModelChildAlgorithm.childId() string, which uniquely identifies which child algorithm the parameter is associated with inside the given model.

A Processing context must also be specified, which allows the widget to resolve parameter values which are context dependent. The context must last for the lifetime of the widget.

Parameters:
createLabel(self) QLabel | None[source]

Creates a label for use identifying the associated parameter.

The caller takes ownership of the returned value.

Return type:

Optional[QLabel]

isModelOutput(self) bool[source]

Returns True if the widget is set to the model output mode.

Added in version 3.14.

Return type:

bool

modelOutputName(self) str[source]

Returns the model output name, if isModelOutput() is True.

See also

isModelOutput()

Added in version 3.14.

Return type:

str

parameterDefinition(self) QgsProcessingParameterDefinition | None[source]

Returns the parameter definition associated with this wrapper.

Return type:

Optional[QgsProcessingParameterDefinition]

populateSources(self, compatibleParameterTypes: Iterable[str | None], compatibleOutputTypes: Iterable[str | None], compatibleDataTypes: Iterable[int])[source]

Populates the widget with available sources for the parameter’s value, e.g. adding the available child algorithm outputs and model input parameter choices.

In order to determine the available source, the compatibleParameterTypes and compatibleOutputTypes arguments are used. These lists correspond to the various available values for QgsProcessingParameterDefinition.type() (for compatibleParameterTypes) and the values for QgsProcessingOutputDefinition.type() (for compatibleOutputTypes).

The compatibleDataTypes list corresponds to the compatible data types from QgsProcessing.SourceType.

Parameters:
  • compatibleParameterTypes (Iterable[Optional[str]])

  • compatibleOutputTypes (Iterable[Optional[str]])

  • compatibleDataTypes (Iterable[int])

registerProcessingContextGenerator(self, generator: QgsProcessingContextGenerator | None)[source]

Registers a Processing context generator class that will be used to retrieve a Processing context for the widget when required.

Parameters:

generator (Optional[QgsProcessingContextGenerator])

setDialog(self, dialog: QDialog | None)[source]

Sets the parent dialog in which the widget is shown.

Added in version 3.8.

Parameters:

dialog (Optional[QDialog])

setExpressionHelpText(self, text: str | None)[source]

Set the expected expression format text, which is shown in the expression builder dialog for the widget when in the “pre-calculated” expression mode. This is purely a text format and no expression validation is made against it.

Parameters:

text (Optional[str])

setSourceType(self, type: Qgis.ProcessingModelChildParameterSource)[source]

Sets the current source type for the parameter.

Added in version 3.24.

Parameters:

type (Qgis.ProcessingModelChildParameterSource)

setToModelOutput(self, value: str | None)[source]

Sets the widget to a model output, for destination parameters only.

See also

isModelOutput()

Added in version 3.14.

Parameters:

value (Optional[str])

setWidgetContext(self, context: QgsProcessingParameterWidgetContext)[source]

Sets the context in which the modeler parameter widget is shown, e.g., the parent model algorithm and other relevant information which allows the widget to fine-tune its behavior.

Parameters:

context (QgsProcessingParameterWidgetContext)

setWidgetValue(self, value: QgsProcessingModelChildParameterSource)[source]

Sets the current value for the parameter.

See also

value()

Parameters:

value (QgsProcessingModelChildParameterSource)

setWidgetValue(self, values: Iterable[QgsProcessingModelChildParameterSource])[source]

Sets the current values for the parameter.

See also

value()

Added in version 3.14.

Parameters:

values (Iterable[QgsProcessingModelChildParameterSource])

value(self) Any[source]

Returns the current value of the parameter.

See also

setWidgetValue()

Return type:

Any