Class: QgsFeatureFilterProvider

Abstract interface for use by classes that filter the features or attributes of a layer.

A QgsFeatureFilterProvider provides a method for modifying a QgsFeatureRequest in place to apply additional filters to the request, since QGIS 3.18 a method to filter allowed attributes is also available.

Note

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

The following methods must be implemented: clone(), layerAttributes()

Class Hierarchy

Inheritance diagram of qgis.core.QgsFeatureFilterProvider

Subclasses

QgsFeatureExpressionFilterProvider

A feature filter provider allowing to set filter expressions on a per-layer basis.

QgsGroupedFeatureFilterProvider

A filter filter provider grouping several filter providers.

QgsAccessControl

A helper class that centralizes restrictions given by all the access control filter plugins.

QgsFeatureFilter

A feature filter provider allowing to set filter expressions on a per-layer basis.

QgsFeatureFilterProviderGroup

A filter filter provider grouping several filter providers.

Abstract Methods

clone

Create a clone of the feature filter provider

layerAttributes

Returns the list of visible attribute names from a list of attributes names for the given layer

Virtual Methods

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

filterFeatures

Add additional filters to the feature request to further restrict the features returned by the request.

isFilterThreadSafe

Returns True if the filterFeature function is thread safe, which will lead to reliance on layer ID instead of the raw layer pointer.

class qgis.core.QgsFeatureFilterProvider[source]

Bases: object

abstract clone(self) QgsFeatureFilterProvider | None[source]

Create a clone of the feature filter provider

Return type:

Optional[QgsFeatureFilterProvider]

Returns:

a new clone

virtual filterFeatures(self, layer: QgsVectorLayer | None, featureRequest: QgsFeatureRequest)[source]

Add additional filters to the feature request to further restrict the features returned by the request. Derived classes must implement this method.

Parameters:

Deprecated since version 4.0: Use the layer ID variant.

virtual filterFeatures(self, layerId: str | None, featureRequest: QgsFeatureRequest)[source]

Add additional filters to the feature request to further restrict the features returned by the request. Derived classes must implement this method.

Parameters:
  • layerId (Optional[str]) – the layer ID to filter

  • featureRequest (QgsFeatureRequest) – the feature request to update

Added in version 4.0.

virtual isFilterThreadSafe(self) bool[source]

Returns True if the filterFeature function is thread safe, which will lead to reliance on layer ID instead of the raw layer pointer.

Added in version 4.0.

Deprecated since version 4.0.

Return type:

bool

abstract layerAttributes(self, layer: QgsVectorLayer | None, attributes: Iterable[str | None]) List[str][source]

Returns the list of visible attribute names from a list of attributes names for the given layer

Added in version 3.18.

Parameters:
  • layer (Optional[QgsVectorLayer])

  • attributes (Iterable[Optional[str]])

Return type:

List[str]