QgsAbstractProcessingParameterWidgetWrapper class

A widget wrapper for Processing parameter value widgets.

Widget wrappers are used to create widgets for individual Processing parameters, and handle retrieving and setting the current value for those parameters.

Widget wrappers can be created for different dialog types, allowing different appearance and behavior of widgets depending on whether they are being created for use in a standard algorithm dialog, a batch processing dialog, or a modeler dialog.

Individual widget wrappers are not usually created directly, instead they are constructed through the central registry, via calls to QgsGui::processingGuiRegistry()->createParameterWidgetWrapper().

Base classes

class QgsExpressionContextGenerator
Abstract interface for generating an expression context.

Constructors, destructors, conversion operators

QgsAbstractProcessingParameterWidgetWrapper(const QgsProcessingParameterDefinition* parameter = nullptr, QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QObject* parent = nullptr)
Constructor for QgsAbstractProcessingParameterWidgetWrapper, for the specified parameter definition and dialog type.

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 createWrappedLabel() -> QLabel*
Creates and returns a new label to accompany widgets created by the wrapper.
auto createWrappedWidget(QgsProcessingContext& context) -> QWidget*
Creates and return a new wrapped widget which allows customization of the parameter's value.
auto parameterDefinition() const -> const QgsProcessingParameterDefinition*
Returns the parameter definition associated with this wrapper.
auto parameterValue() const -> QVariant
Returns the current value of the parameter.
void postInitialize(const QList<QgsAbstractProcessingParameterWidgetWrapper*>& wrappers) virtual
Called after all wrappers have been created within a particular dialog or context, allowing the wrapper to connect to the wrappers of other, related parameters.
void registerProcessingContextGenerator(QgsProcessingContextGenerator* generator)
Registers a Processing context generator class that will be used to retrieve a Processing context for the wrapper when required.
void setParameterValue(const QVariant& value, QgsProcessingContext& context)
Sets the current value for the parameter.
void setWidgetContext(const QgsProcessingParameterWidgetContext& context) virtual
Sets the context in which the Processing parameter widget is shown, e.g., the parent model algorithm, a linked map canvas, and other relevant information which allows the widget to fine-tune its behavior.
auto type() const -> QgsProcessingGui::WidgetType
Returns the dialog type for which widgets and labels will be created by this wrapper.
auto widgetContext() const -> const QgsProcessingParameterWidgetContext&
Returns the context in which the Processing parameter widget is shown, e.g., the parent model algorithm, a linked map canvas, and other relevant information which allows the widget to fine-tune its behavior.
auto wrappedLabel() -> QLabel*
Returns the current wrapped label, if any.
auto wrappedWidget() -> QWidget*
Returns the current wrapped widget, if any.

Signals

void widgetValueHasChanged(QgsAbstractProcessingParameterWidgetWrapper* wrapper)
Emitted whenever the parameter value (as defined by the wrapped widget) is changed.

Protected functions

auto createLabel() -> QLabel* virtual
Creates a new label to accompany widgets created by the wrapper.
auto createWidget() -> QWidget* pure virtual
Creates a new widget which allows customization of the parameter's value.
void setWidgetValue(const QVariant& value, QgsProcessingContext& context) pure virtual
Sets the current value for the parameter to show in the widget.
auto widgetValue() const -> QVariant pure virtual
Returns the current value of the parameter.

Function documentation

QgsExpressionContext QgsAbstractProcessingParameterWidgetWrapper::createExpressionContext() const override

This method needs to be reimplemented in all classes which implement this interface and return an expression context.

QLabel* QgsAbstractProcessingParameterWidgetWrapper::createWrappedLabel()

Creates and returns a new label to accompany widgets created by the wrapper.

The caller takes ownership of the returned label. Some parameter type and dialog type combinations will return nullptr for this method. If nullptr is returned, then no label should be shown for the parameter's widget (i.e. the label is embedded inside the widget itself).

The wrapped label can be retrieved at a later stage by calling wrappedLabel().

QWidget* QgsAbstractProcessingParameterWidgetWrapper::createWrappedWidget(QgsProcessingContext& context)

Creates and return a new wrapped widget which allows customization of the parameter's value.

The caller takes ownership of the returned widget. The wrapped widget can be retrieved at a later stage by calling wrappedWidget().

The supplied context is used while initializing the widget to the parameter's default value.

QVariant QgsAbstractProcessingParameterWidgetWrapper::parameterValue() const

Returns the current value of the parameter.

void QgsAbstractProcessingParameterWidgetWrapper::setParameterValue(const QVariant& value, QgsProcessingContext& context)

Sets the current value for the parameter.

The context argument is used to specify the wider Processing context which the current value is associated with.

void QgsAbstractProcessingParameterWidgetWrapper::setWidgetContext(const QgsProcessingParameterWidgetContext& context) virtual

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

Subclasses should take care to call the base class method when reimplementing this method.

const QgsProcessingParameterWidgetContext& QgsAbstractProcessingParameterWidgetWrapper::widgetContext() const

Returns the context in which the Processing parameter widget is shown, e.g., the parent model algorithm, a linked map canvas, and other relevant information which allows the widget to fine-tune its behavior.

QLabel* QgsAbstractProcessingParameterWidgetWrapper::wrappedLabel()

Returns the current wrapped label, if any.

QWidget* QgsAbstractProcessingParameterWidgetWrapper::wrappedWidget()

Returns the current wrapped widget, if any.

QLabel* QgsAbstractProcessingParameterWidgetWrapper::createLabel() virtual protected

Creates a new label to accompany widgets created by the wrapper.

The caller takes ownership of the returned label. Some parameter type and dialog type combinations will return nullptr for this method. If nullptr is returned, then no label should be shown for the parameter's widget (i.e. the label is embedded inside the widget itself).

QWidget* QgsAbstractProcessingParameterWidgetWrapper::createWidget() pure virtual protected

Creates a new widget which allows customization of the parameter's value.

The caller takes ownership of the returned widget.

void QgsAbstractProcessingParameterWidgetWrapper::setWidgetValue(const QVariant& value, QgsProcessingContext& context) pure virtual protected

Sets the current value for the parameter to show in the widget.

The context argument is used to specify the wider Processing context which the current value is associated with.

QVariant QgsAbstractProcessingParameterWidgetWrapper::widgetValue() const pure virtual protected

Returns the current value of the parameter.