QgsMapLayerLegend class

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

Derived classes

class QgsDefaultMeshLayerLegend
Default legend implementation for mesh layers.
class QgsDefaultRasterLayerLegend
Default legend implementation for raster layers.
class QgsDefaultVectorLayerLegend
Default legend implementation for vector layers.

Public static functions

static auto defaultMeshLegend(QgsMeshLayer* ml) -> QgsMapLayerLegend*
Create new legend implementation for mesh layer.
static auto defaultRasterLegend(QgsRasterLayer* rl) -> QgsMapLayerLegend*
Create new legend implementation for raster layer.
static auto defaultVectorLegend(QgsVectorLayer* vl) -> QgsMapLayerLegend*
Create new legend implementation for vector layer.

Constructors, destructors, conversion operators

QgsMapLayerLegend(QObject* parent = nullptr) explicit
Constructor for QgsMapLayerLegend.

Public functions

auto createLayerTreeModelLegendNodes(QgsLayerTreeLayer* nodeLayer) -> QList<QgsLayerTreeModelLegendNode*> pure virtual
Returns list of legend nodes to be used for a particular layer tree layer node.
void readXml(const QDomElement& elem, const QgsReadWriteContext& context) virtual
Reads configuration from a DOM element previously written by writeXml()
auto writeXml(QDomDocument& doc, const QgsReadWriteContext& context) const -> QDomElement virtual
Writes configuration to a DOM element, to be used later with readXml()

Signals

void itemsChanged()
Emitted when existing items/nodes got invalid and should be replaced by new ones.

Function documentation

QList<QgsLayerTreeModelLegendNode*> QgsMapLayerLegend::createLayerTreeModelLegendNodes(QgsLayerTreeLayer* nodeLayer) pure virtual

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

Ownership is transferred to the caller.

void QgsMapLayerLegend::readXml(const QDomElement& elem, const QgsReadWriteContext& context) virtual

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

QDomElement QgsMapLayerLegend::writeXml(QDomDocument& doc, const QgsReadWriteContext& context) const virtual

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