Class: QgsLegendFilterButton

A tool button that allows enabling or disabling legend filter by contents of the map. An additional pop down menu allows defining a boolean expression to refine the filtering.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsLegendFilterButton

Base classes

QToolButton

QAbstractButton

QWidget

QObject

QPaintDevice

Methods

expressionText

Returns the current text used as filter expression

registerExpressionContextGenerator

Register an expression context generator class that will be used to retrieve an expression context for the button when required.

setExpressionText

Sets the current text used as filter expression.

setVectorLayer

Sets the associated vectorLayer May be None

vectorLayer

Returns the current associated vectorLayer May be None

Signals

expressionTextChanged

Emitted when the expression text changes

class qgis.gui.QgsLegendFilterButton[source]

Bases: QToolButton

__init__(parent: QWidget | None = None)

Construct a new filter legend button

Parameters:

parent (Optional[QWidget] = None) – The parent QWidget

expressionText(self) str[source]

Returns the current text used as filter expression

Return type:

str

signal expressionTextChanged[source]

Emitted when the expression text changes

registerExpressionContextGenerator(self, generator: QgsExpressionContextGenerator | None)[source]

Register an expression context generator class that will be used to retrieve an expression context for the button when required.

Added in version 3.32.

Parameters:

generator (Optional[QgsExpressionContextGenerator])

setExpressionText(self, expression: str | None)[source]

Sets the current text used as filter expression. This will update the menu

Parameters:

expression (Optional[str])

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

Sets the associated vectorLayer May be None

Parameters:

layer (Optional[QgsVectorLayer])

vectorLayer(self) QgsVectorLayer | None[source]

Returns the current associated vectorLayer May be None

Return type:

Optional[QgsVectorLayer]