QgsProcessingModelerParameterWidget class
A widget for customising the value of Processing algorithm parameter inside a Processing model.
Contents
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::
Base classes
- class QgsExpressionContextGenerator
- Abstract interface for generating an expression context.
Constructors, destructors, conversion operators
- QgsProcessingModelerParameterWidget(QgsProcessingModelAlgorithm* model, const QString& childId, const QgsProcessingParameterDefinition* parameter, QgsProcessingContext& context, QWidget* parent = nullptr)
- Constructor for QgsProcessingModelerParameterWidget, for the specified parameter definition within the given model.
Public functions
- auto createExpressionContext() const -> QgsExpressionContext override
- This method needs to be reimplemented in all classes which implement this interface and return an expression context.
- auto createLabel() -> QLabel*
- Creates a label for use identifying the associated parameter.
- auto parameterDefinition() const -> const QgsProcessingParameterDefinition*
- Returns the parameter definition associated with this wrapper.
- void populateSources(const QStringList& compatibleParameterTypes, const QStringList& compatibleOutputTypes, const QList<int>& compatibleDataTypes)
- Populates the widget with available sources for the parameter's value, e.g.
- void registerProcessingContextGenerator(QgsProcessingContextGenerator* generator)
- Registers a Processing context generator class that will be used to retrieve a Processing context for the widget when required.
- void setExpressionHelpText(const QString& text)
- Set the expected expression format text, which is shown in the expression builder dialog for the widget when in the "pre-calculated" expression mode.
- void setWidgetContext(const QgsProcessingParameterWidgetContext& context)
- 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.
- void setWidgetValue(const QgsProcessingModelChildParameterSource& value) virtual
- Sets the current value for the parameter.
- auto value() const -> QgsProcessingModelChildParameterSource virtual
- Returns the current value of the parameter.
Function documentation
QgsProcessingModelerParameterWidget:: QgsProcessingModelerParameterWidget(QgsProcessingModelAlgorithm* model,
const QString& childId,
const QgsProcessingParameterDefinition* parameter,
QgsProcessingContext& context,
QWidget* parent = nullptr)
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.
QgsExpressionContext QgsProcessingModelerParameterWidget:: createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an expression context.
QLabel* QgsProcessingModelerParameterWidget:: createLabel()
Creates a label for use identifying the associated parameter.
The caller takes ownership of the returned value.
void QgsProcessingModelerParameterWidget:: populateSources(const QStringList& compatibleParameterTypes,
const QStringList& compatibleOutputTypes,
const QList<int>& compatibleDataTypes)
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::
The compatibleDataTypes list corresponds to the compatible data types from QgsProcessing::
void QgsProcessingModelerParameterWidget:: setExpressionHelpText(const QString& text)
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.
void QgsProcessingModelerParameterWidget:: setWidgetValue(const QgsProcessingModelChildParameterSource& value) virtual
Sets the current value for the parameter.
QgsProcessingModelChildParameterSource QgsProcessingModelerParameterWidget:: value() const virtual
Returns the current value of the parameter.