Class: QgsFeaturePickerWidget

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.

Added in version 3.14.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsFeaturePickerWidget

Base classes

QWidget

QObject

QPaintDevice

Methods

allowNull

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

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.

feature

Returns the current feature

fetchGeometry

Returns if the geometry is fetched

fetchLimit

Returns the feature request fetch limit

filterExpression

An additional expression to further restrict the available features.

layer

The layer from which features should be listed.

nullIndex

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

setAllowNull

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

setDisplayExpression

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

setFeature

Sets the current index by using the given feature

setFetchGeometry

Defines if the geometry will be fetched

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.

setLayer

The layer from which features should be listed.

setShowBrowserButtons

Defines if the browsing buttons are shown

showBrowserButtons

Returns if the browsing buttons are shown

Signals

allowNullChanged

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

displayExpressionChanged

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

featureChanged

Sends the feature as soon as it is chosen

fetchGeometryChanged

Emitted when the fetching of the geometry changes

fetchLimitChanged

Emitted when the fetching limit for the feature request changes

filterExpressionChanged

An additional expression to further restrict the available features.

layerChanged

The layer from which features should be listed.

modelUpdated

The underlying model has been updated.

showBrowserButtonsChanged

Emitted when showing the browser buttons changes

class qgis.gui.QgsFeaturePickerWidget[source]

Bases: QWidget

__init__(parent: QWidget | None = None)

Create a new QgsFeaturePickerWidget, 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.

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.

feature(self) QgsFeature[source]

Returns the current feature

Return type:

QgsFeature

signal featureChanged(feature: QgsFeature)[source]

Sends the feature as soon as it is chosen

Parameters:

feature (QgsFeature)

fetchGeometry(self) bool[source]

Returns if the geometry is fetched

Return type:

bool

signal fetchGeometryChanged[source]

Emitted when the fetching of the geometry changes

fetchLimit(self) int[source]

Returns the feature request fetch limit

Return type:

int

signal fetchLimitChanged[source]

Emitted when the fetching limit for the feature request changes

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.

layer(self) QgsVectorLayer | None[source]

The layer from which features should be listed.

Return type:

Optional[QgsVectorLayer]

signal layerChanged[source]

The layer from which features should be listed.

signal modelUpdated[source]

The underlying model has been updated.

nullIndex(self) int[source]

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

Return type:

int

setAllowNull(self, allowNull: bool)[source]

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

Parameters:

allowNull (bool)

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])

setFeature(self, featureId: int)[source]

Sets the current index by using the given feature

Parameters:

featureId (int)

setFetchGeometry(self, fetchGeometry: bool)[source]

Defines if the geometry will be fetched

Parameters:

fetchGeometry (bool)

setFetchLimit(self, fetchLimit: int)[source]

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

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])

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

The layer from which features should be listed.

Parameters:

layer (Optional[QgsVectorLayer])

setShowBrowserButtons(self, showBrowserButtons: bool)[source]

Defines if the browsing buttons are shown

Note

Buttons are browsing the currently fetched features. If a limit is set, there might be more features to be fetched from the layer.

Parameters:

showBrowserButtons (bool)

showBrowserButtons(self) bool[source]

Returns if the browsing buttons are shown

Return type:

bool

signal showBrowserButtonsChanged[source]

Emitted when showing the browser buttons changes