Class: QgsProcessingAbstractParameterDefinitionWidget

Abstract base class for widgets which allow users to specify the properties of a Processing parameter.

Added in version 3.10.

Note

This is an abstract class, with methods which must be implemented by a subclass.

The following methods must be implemented: createParameter()

Class Hierarchy

Inheritance diagram of qgis.gui.QgsProcessingAbstractParameterDefinitionWidget

Base classes

QWidget

QObject

QPaintDevice

QgsExpressionContextGenerator

Abstract interface for generating an expression context.

Abstract Methods

createParameter

Returns a new instance of a parameter definition, using the current settings defined in the dialog.

Methods

registerProcessingContextGenerator

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

widgetContext

Returns the context in which the Processing definition 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.

Virtual Methods

In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of QgsProcessingAbstractParameterDefinitionWidget. See the FAQ for more details.

setWidgetContext

Sets the context in which the Processing definition 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.

class qgis.gui.QgsProcessingAbstractParameterDefinitionWidget[source]

Bases: QWidget, QgsExpressionContextGenerator

__init__(context: QgsProcessingContext, widgetContext: QgsProcessingParameterWidgetContext, definition: QgsProcessingParameterDefinition | None = None, algorithm: QgsProcessingAlgorithm | None = None, parent: QWidget | None = None)

Creates a new QgsProcessingAbstractParameterDefinitionWidget, with the specified parent widget.

The context argument must specify a Processing context, which will be used by the widget to evaluate existing definition properties such as default values. Similarly, the widgetContext argument specifies the wider GUI context in which the widget will be used.

The optional definition argument may be used to provide a parameter definition to use to initially populate the widget’s state.

Additionally, the optional algorithm parameter may be used to specify the algorithm or model associated with the parameter.

Parameters:
abstract createParameter(self, name: str | None, description: str | None, flags: Qgis.ProcessingParameterFlags | Qgis.ProcessingParameterFlag) QgsProcessingParameterDefinition | None[source]

Returns a new instance of a parameter definition, using the current settings defined in the dialog.

Common properties for parameters, including the name, description, and parameter flags are passed to the method. Subclass implementations must use these properties when crafting a parameter definition which also respects the additional properties specific to the parameter type handled by the widget subclass.

Parameters:
Return type:

Optional[QgsProcessingParameterDefinition]

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.

Added in version 3.18.

Parameters:

generator (Optional[QgsProcessingContextGenerator])

virtual setWidgetContext(self, context: QgsProcessingParameterWidgetContext)[source]

Sets the context in which the Processing definition 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.

See also

widgetContext()

Added in version 3.18.

Parameters:

context (QgsProcessingParameterWidgetContext)

widgetContext(self) QgsProcessingParameterWidgetContext

Returns the context in which the Processing definition 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.

Added in version 3.18.

Return type:

QgsProcessingParameterWidgetContext