QgsDefaultVectorLayerLegend class

Default legend implementation for vector layers.

Contents

Base classes

class QgsMapLayerLegend
The QgsMapLayerLegend class is abstract interface for implementations of legends for one map layer.

Public functions

auto createLayerTreeModelLegendNodes(QgsLayerTreeLayer* nodeLayer) -> QList<QgsLayerTreeModelLegendNode*> override
Returns list of legend nodes to be used for a particular layer tree layer node.
void readXml(const QDomElement& elem, const QgsReadWriteContext& context) override
Reads configuration from a DOM element previously written by writeXml()
void setTextOnSymbolContent(const QHash<QString, QString>& content)
Sets per-symbol content of labels for "text on symbol" functionality.
void setTextOnSymbolEnabled(bool enabled)
Sets whether the "text on symbol" functionality is enabled.
void setTextOnSymbolTextFormat(const QgsTextFormat& format)
Sets text format of symbol labels for "text on symbol" functionality.
auto textOnSymbolContent() const -> QHash<QString, QString>
Returns per-symbol content of labels for "text on symbol" functionality.
auto textOnSymbolEnabled() const -> bool
Returns whether the "text on symbol" functionality is enabled.
auto textOnSymbolTextFormat() const -> QgsTextFormat
Returns text format of symbol labels for "text on symbol" functionality.
auto writeXml(QDomDocument& doc, const QgsReadWriteContext& context) const -> QDomElement override
Writes configuration to a DOM element, to be used later with readXml()

Function documentation

QList<QgsLayerTreeModelLegendNode*> QgsDefaultVectorLayerLegend::createLayerTreeModelLegendNodes(QgsLayerTreeLayer* nodeLayer) override

Returns list of legend nodes to be used for a particular layer tree layer node.

Ownership is transferred to the caller.

void QgsDefaultVectorLayerLegend::readXml(const QDomElement& elem, const QgsReadWriteContext& context) override

Reads configuration from a DOM element previously written by writeXml()

void QgsDefaultVectorLayerLegend::setTextOnSymbolContent(const QHash<QString, QString>& content)

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.

void QgsDefaultVectorLayerLegend::setTextOnSymbolEnabled(bool enabled)

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().

void QgsDefaultVectorLayerLegend::setTextOnSymbolTextFormat(const QgsTextFormat& format)

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

QHash<QString, QString> QgsDefaultVectorLayerLegend::textOnSymbolContent() const

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.

bool QgsDefaultVectorLayerLegend::textOnSymbolEnabled() const

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().

QgsTextFormat QgsDefaultVectorLayerLegend::textOnSymbolTextFormat() const

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

QDomElement QgsDefaultVectorLayerLegend::writeXml(QDomDocument& doc, const QgsReadWriteContext& context) const override

Writes configuration to a DOM element, to be used later with readXml()