Class: QgsLayerTreeViewIndicator

Indicator that can be used in a layer tree view to display icons next to items of the layer tree.

They add extra context to the item and interactivity (using clicked() signal).

Indicators can be added/removed to individual layer tree items using QgsLayerTreeView.addIndicator() and QgsLayerTreeView.removeIndicator() calls.

Added in version 3.2.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsLayerTreeViewIndicator

Base classes

QObject

Methods

icon

Indicator icon that will be displayed in the layer tree view

setIcon

Sets indicator icon that will be displayed in the layer tree view

setToolTip

Sets tool tip text

toolTip

Returns tool tip text that will be shown when user hovers mouse over the indicator

Signals

changed

Emitted when the indicator changes state (e.g. icon).

clicked

Emitted when user clicks on the indicator

class qgis.gui.QgsLayerTreeViewIndicator[source]

Bases: QObject

__init__(parent: QObject | None = None)

Constructs an indicator, optionally transferring ownership to a parent QObject

Parameters:

parent (Optional[QObject] = None)

signal changed[source]

Emitted when the indicator changes state (e.g. icon).

Added in version 3.10.

signal clicked(index: QModelIndex)[source]

Emitted when user clicks on the indicator

Parameters:

index (QModelIndex)

icon(self) QIcon[source]

Indicator icon that will be displayed in the layer tree view

Return type:

QIcon

setIcon(self, icon: QIcon)[source]

Sets indicator icon that will be displayed in the layer tree view

Parameters:

icon (QIcon)

setToolTip(self, tip: str | None)[source]

Sets tool tip text

Parameters:

tip (Optional[str])

toolTip(self) str[source]

Returns tool tip text that will be shown when user hovers mouse over the indicator

Return type:

str