Class: QgsProcessingMapLayerComboBox

Processing map layer combo box.

Warning

Not part of stable API and may change in future QGIS releases.

Added in version 3.8.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsProcessingMapLayerComboBox

Base classes

QWidget

QObject

QPaintDevice

Methods

currentLayer

Returns the current layer selected in the combobox, or None if the selection cannot be represented as a map layer.

currentText

Returns the current text of the selected item in the combobox.

isEditable

Returns whether the combo box value can be freely edited.

setEditable

Sets whether the combo box value can be freely edited.

setLayer

Sets the combo box to the specified layer, if layer is compatible with the widget's parameter definition.

setValue

Sets the value shown in the widget.

setWidgetContext

Sets the context in which the widget is shown.

value

Returns the current value of the widget.

Signals

valueChanged

Emitted whenever the value is changed in the widget.

class qgis.gui.QgsProcessingMapLayerComboBox[source]

Bases: QWidget

__init__(parameter: QgsProcessingParameterDefinition | None, type: QgsProcessingGui.WidgetType = QgsProcessingGui.Standard, parent: QWidget | None = None)

Constructor for QgsProcessingMapLayerComboBox, with the specified parameter definition.

Parameters:
currentLayer(self) QgsMapLayer | None[source]

Returns the current layer selected in the combobox, or None if the selection cannot be represented as a map layer.

Warning

Prefer calling value() instead, as it correctly encapsulates all valid values which can be represented by the widget.

See also

currentText()

Return type:

Optional[QgsMapLayer]

currentText(self) str[source]

Returns the current text of the selected item in the combobox.

Warning

Prefer calling value() instead, as it correctly encapsulates all valid values which can be represented by the widget.

See also

currentLayer()

Return type:

str

isEditable(self) bool[source]

Returns whether the combo box value can be freely edited.

See also

setEditable()

Added in version 3.14.

Return type:

bool

setEditable(self, editable: bool)[source]

Sets whether the combo box value can be freely edited.

See also

isEditable()

Added in version 3.14.

Parameters:

editable (bool)

setLayer(self, layer: QgsMapLayer | None)[source]

Sets the combo box to the specified layer, if layer is compatible with the widget’s parameter definition.

Parameters:

layer (Optional[QgsMapLayer])

setValue(self, value: Any, context: QgsProcessingContext)[source]

Sets the value shown in the widget.

See also

value()

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

Sets the context in which the widget is shown.

Added in version 3.14.

Parameters:

context (QgsProcessingParameterWidgetContext)

value(self) Any[source]

Returns the current value of the widget.

See also

setValue()

Return type:

Any

signal valueChanged[source]

Emitted whenever the value is changed in the widget.