Class: QgsMapLayerLegend

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

Class Hierarchy

Inheritance diagram of qgis.core.QgsMapLayerLegend

Base classes

QObject

Subclasses

QgsDefaultMeshLayerLegend

Default legend implementation for mesh layers

QgsDefaultPointCloudLayerLegend

Default legend implementation for point cloud layers

QgsDefaultRasterLayerLegend

Default legend implementation for raster layers

QgsDefaultVectorLayerLegend

Default legend implementation for vector layers

class qgis.core.QgsMapLayerLegend[source]

Bases: QObject

__init__(parent: QObject | None = None)

Constructor for QgsMapLayerLegend

Parameters:

parent (Optional[QObject] = None)

createLayerTreeModelLegendNodes(self, nodeLayer: QgsLayerTreeLayer | None) List[QgsLayerTreeModelLegendNode]

Returns list of legend nodes to be used for a particular layer tree layer node. Ownership is transferred to the caller.

Parameters:

nodeLayer (Optional[QgsLayerTreeLayer])

Return type:

List[QgsLayerTreeModelLegendNode]

static defaultMeshLegend(ml: QgsMeshLayer | None) QgsMapLayerLegend | None[source]

Create new legend implementation for mesh layer

Parameters:

ml (Optional[QgsMeshLayer])

Return type:

Optional[QgsMapLayerLegend]

static defaultPointCloudLegend(layer: QgsPointCloudLayer | None) QgsMapLayerLegend | None[source]

Create new legend implementation for a point cloud layer.

Added in version 3.18.

Parameters:

layer (Optional[QgsPointCloudLayer])

Return type:

Optional[QgsMapLayerLegend]

static defaultRasterLegend(rl: QgsRasterLayer | None) QgsMapLayerLegend | None[source]

Create new legend implementation for raster layer

Parameters:

rl (Optional[QgsRasterLayer])

Return type:

Optional[QgsMapLayerLegend]

static defaultVectorLegend(vl: QgsVectorLayer | None) QgsMapLayerLegend | None[source]

Create new legend implementation for vector layer

Parameters:

vl (Optional[QgsVectorLayer])

Return type:

Optional[QgsMapLayerLegend]

signal itemsChanged[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

readXml(self, elem: QDomElement, context: QgsReadWriteContext)[source]

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

Added in version 3.2.

Parameters:
writeXml(self, doc: QDomDocument, context: QgsReadWriteContext) QDomElement[source]

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

Added in version 3.2.

Parameters:
Return type:

QDomElement