Class: QgsFeatureListComboBox

This offers a combobox with autocompleter that allows selecting features from a layer.

It will show up to 100 entries at a time. The entries can be chosen based on the displayExpression and whenever text is typed into the combobox, the completer and popup will adjust to features matching the typed text.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsFeatureListComboBox

Base classes

QComboBox

QWidget

QObject

QPaintDevice

Methods

allowNull

Determines if a NULL value should be available in the list.

currentFeatureRequest

Shorthand for getting a feature request to query the currently selected feature.

currentModelIndex

The index of the currently selected item.

displayExpression

The display expression will be used to display features as well as the value to match the typed text against.

fetchLimit

Returns the feature request fetch limit

filterExpression

An additional expression to further restrict the available features.

formFeature

Returns an attribute form feature to be used with the filter expression.

identifierField

Field name that will be used to uniquely identify the current feature.

identifierFields

Field name that will be used to uniquely identify the current feature.

identifierValue

The identifier value of the currently selected feature.

identifierValues

The identifier values of the currently selected feature.

nullIndex

Returns the current index of the NULL value, or -1 if NULL values are not allowed.

parentFormFeature

Returns a parent attribute form feature to be used with the filter expression.

setAllowNull

Determines if a NULL value should be available in the list.

setCurrentFeature

Sets the current index by using the given feature

setDisplayExpression

The display expression will be used to display features as well as the value to match the typed text against.

setFetchLimit

Defines the feature request fetch limit If set to 0, no limit is applied when fetching

setFilterExpression

An additional expression to further restrict the available features.

setFormFeature

Sets an attribute form feature to be used with the filter expression.

setIdentifierField

Field name that will be used to uniquely identify the current feature.

setIdentifierFields

Field name that will be used to uniquely identify the current feature.

setIdentifierValue

The identifier value of the currently selected feature.

setIdentifierValues

The identifier values of the currently selected feature.

setIdentifierValuesToNull

Sets the identifier values of the currently selected feature to NULL

setParentFormFeature

Sets a parent attribute form feature to be used with the filter expression.

setSourceLayer

The layer from which features should be listed.

sourceLayer

The layer from which features should be listed.

Signals

allowNullChanged

Determines if a NULL value should be available in the list.

currentFeatureChanged

Emitted when the current feature changes

currentFeatureFoundChanged

Emitted when the feature picker model changes its feature found state

displayExpressionChanged

The display expression will be used to display features as well as the the value to match the typed text against.

filterExpressionChanged

An additional expression to further restrict the available features.

formFeatureChanged

An attribute form feature to be used alongside the filter expression.

identifierFieldChanged

Field name that will be used to uniquely identify the current feature.

identifierValueChanged

The identifier value of the currently selected feature.

modelUpdated

The underlying model has been updated.

parentFormFeatureChanged

A parent attribute form feature to be used alongside the filter expression.

sourceLayerChanged

The layer from which features should be listed.

class qgis.gui.QgsFeatureListComboBox[source]

Bases: QComboBox

__init__(parent: QWidget | None = None)

Create a new QgsFeatureListComboBox, optionally specifying a parent.

Parameters:

parent (Optional[QWidget] = None)

allowNull(self) bool[source]

Determines if a NULL value should be available in the list.

Return type:

bool

signal allowNullChanged[source]

Determines if a NULL value should be available in the list.

signal currentFeatureChanged[source]

Emitted when the current feature changes

Added in version 3.16.5.

signal currentFeatureFoundChanged(found: bool)[source]

Emitted when the feature picker model changes its feature found state

Added in version 3.38.

Parameters:

found (bool)

currentFeatureRequest(self) QgsFeatureRequest[source]

Shorthand for getting a feature request to query the currently selected feature.

Return type:

QgsFeatureRequest

currentModelIndex(self) QModelIndex[source]

The index of the currently selected item.

Return type:

QModelIndex

displayExpression(self) str[source]

The display expression will be used to display features as well as the value to match the typed text against.

Return type:

str

signal displayExpressionChanged[source]

The display expression will be used to display features as well as the the value to match the typed text against.

fetchLimit(self) int[source]

Returns the feature request fetch limit

Added in version 3.32.

Return type:

int

filterExpression(self) str[source]

An additional expression to further restrict the available features. This can be used to integrate additional spatial or other constraints.

Return type:

str

signal filterExpressionChanged[source]

An additional expression to further restrict the available features. This can be used to integrate additional spatial or other constraints.

formFeature(self) QgsFeature[source]

Returns an attribute form feature to be used with the filter expression.

Added in version 3.42.2.

Return type:

QgsFeature

signal formFeatureChanged[source]

An attribute form feature to be used alongside the filter expression.

Added in version 3.42.2.

identifierField(self) str[source]

Field name that will be used to uniquely identify the current feature. Normally the primary key of the layer.

Deprecated since version 3.10.

Return type:

str

signal identifierFieldChanged[source]

Field name that will be used to uniquely identify the current feature. Normally the primary key of the layer.

identifierFields(self) List[str][source]

Field name that will be used to uniquely identify the current feature. Normally the primary key of the layer.

Added in version 3.10.

Return type:

List[str]

identifierValue(self) Any[source]

The identifier value of the currently selected feature. A value from the identifierField.

Deprecated since version 3.10.

Return type:

Any

signal identifierValueChanged[source]

The identifier value of the currently selected feature. A value from the identifierField.

identifierValues(self) List[Any][source]

The identifier values of the currently selected feature. A value from the identifierField.

Added in version 3.10.

Return type:

List[Any]

signal modelUpdated[source]

The underlying model has been updated.

Added in version 3.2.

nullIndex(self) int[source]

Returns the current index of the NULL value, or -1 if NULL values are not allowed.

Added in version 3.2.

Return type:

int

parentFormFeature(self) QgsFeature[source]

Returns a parent attribute form feature to be used with the filter expression.

Added in version 3.42.2.

Return type:

QgsFeature

signal parentFormFeatureChanged[source]

A parent attribute form feature to be used alongside the filter expression.

Added in version 3.42.2.

setAllowNull(self, allowNull: bool)[source]

Determines if a NULL value should be available in the list.

Parameters:

allowNull (bool)

setCurrentFeature(self, feature: QgsFeature)[source]

Sets the current index by using the given feature

Added in version 3.10.

Parameters:

feature (QgsFeature)

setDisplayExpression(self, displayExpression: str | None)[source]

The display expression will be used to display features as well as the value to match the typed text against.

Parameters:

displayExpression (Optional[str])

setFetchLimit(self, fetchLimit: int)[source]

Defines the feature request fetch limit If set to 0, no limit is applied when fetching

Added in version 3.32.

Parameters:

fetchLimit (int)

setFilterExpression(self, filterExpression: str | None)[source]

An additional expression to further restrict the available features. This can be used to integrate additional spatial or other constraints.

Parameters:

filterExpression (Optional[str])

setFormFeature(self, feature: QgsFeature)[source]

Sets an attribute form feature to be used with the filter expression.

Added in version 3.42.2.

Parameters:

feature (QgsFeature)

setIdentifierField(self, identifierField: str | None)[source]

Field name that will be used to uniquely identify the current feature. Normally the primary key of the layer.

Deprecated since version 3.10.

Parameters:

identifierField (Optional[str])

setIdentifierFields(self, identifierFields: Iterable[str | None])[source]

Field name that will be used to uniquely identify the current feature. Normally the primary key of the layer.

Added in version 3.10.

Parameters:

identifierFields (Iterable[Optional[str]])

setIdentifierValue(self, identifierValue: Any)[source]

The identifier value of the currently selected feature. A value from the identifierField.

Deprecated since version 3.10: Use setIdentifierValues.

Parameters:

identifierValue (Any)

setIdentifierValues(self, identifierValues: Iterable[Any])[source]

The identifier values of the currently selected feature. A value from the identifierFields.

Added in version 3.10.

Parameters:

identifierValues (Iterable[Any])

setIdentifierValuesToNull(self)[source]

Sets the identifier values of the currently selected feature to NULL

QgsFeatureListComboBox.setIdentifierValuesToNull(s).

setIdentifierValuesToNull(s).

Added in version 3.10.

setParentFormFeature(self, feature: QgsFeature)[source]

Sets a parent attribute form feature to be used with the filter expression.

Added in version 3.42.2.

Parameters:

feature (QgsFeature)

setSourceLayer(self, sourceLayer: QgsVectorLayer | None)[source]

The layer from which features should be listed.

Parameters:

sourceLayer (Optional[QgsVectorLayer])

sourceLayer(self) QgsVectorLayer | None[source]

The layer from which features should be listed.

Return type:

Optional[QgsVectorLayer]

signal sourceLayerChanged[source]

The layer from which features should be listed.