Class: QgsDefaultVectorLayerLegend

Default legend implementation for vector layers.

Class Hierarchy

Inheritance diagram of qgis.core.QgsDefaultVectorLayerLegend

Base classes

QgsMapLayerLegend

An abstract interface for implementations of legends for one map layer.

QObject

Methods

setShowLabelLegend

Sets if a legend for the labeling should be shown

setTextOnSymbolContent

Sets per-symbol content of labels for "text on symbol" functionality.

setTextOnSymbolEnabled

Sets whether the "text on symbol" functionality is enabled.

setTextOnSymbolTextFormat

Sets text format of symbol labels for "text on symbol" functionality.

showLabelLegend

Returns whether the legend for the labeling is shown

textOnSymbolContent

Returns per-symbol content of labels for "text on symbol" functionality.

textOnSymbolEnabled

Returns whether the "text on symbol" functionality is enabled.

textOnSymbolTextFormat

Returns text format of symbol labels for "text on symbol" functionality.

class qgis.core.QgsDefaultVectorLayerLegend[source]

Bases: QgsMapLayerLegend

setShowLabelLegend(self, enabled: bool)[source]

Sets if a legend for the labeling should be shown

Parameters:

enabled (bool) – true to show label legend entries

Added in version 3.20.

setTextOnSymbolContent(self, content: Dict[str | None, str | None])[source]

Sets per-symbol content of labels for “text on symbol” functionality. In the passed dictionary the keys are rule keys of legend items, the values are labels to be shown.

Added in version 3.2.

Parameters:

content (Dict[Optional[str], Optional[str]])

setTextOnSymbolEnabled(self, enabled: bool)[source]

Sets whether the “text on symbol” functionality is enabled. When enabled, legend symbols may have extra text rendered on top. The content of labels and their style is controlled by textOnSymbolContent() and textOnSymbolTextFormat().

Added in version 3.2.

Parameters:

enabled (bool)

setTextOnSymbolTextFormat(self, format: QgsTextFormat)[source]

Sets text format of symbol labels for “text on symbol” functionality.

Added in version 3.2.

Parameters:

format (QgsTextFormat)

showLabelLegend(self) bool[source]

Returns whether the legend for the labeling is shown

Added in version 3.20.

Return type:

bool

textOnSymbolContent(self) Dict[str, str]

Returns per-symbol content of labels for “text on symbol” functionality. In the passed dictionary the keys are rule keys of legend items, the values are labels to be shown.

Added in version 3.2.

Return type:

Dict[str, str]

textOnSymbolEnabled(self) bool[source]

Returns whether the “text on symbol” functionality is enabled. When enabled, legend symbols may have extra text rendered on top. The content of labels and their style is controlled by textOnSymbolContent() and textOnSymbolTextFormat().

Added in version 3.2.

Return type:

bool

textOnSymbolTextFormat(self) QgsTextFormat[source]

Returns text format of symbol labels for “text on symbol” functionality.

Added in version 3.2.

Return type:

QgsTextFormat