Class: QgsMapLayerLegend¶
An abstract interface for implementations of legends for one map layer.
Note
This is an abstract class, with methods which must be implemented by a subclass.
The following methods must be implemented: createLayerTreeModelLegendNodes()
Class Hierarchy¶
Base classes¶
Subclasses¶
Default legend implementation for mesh layers. |
|
Default legend implementation for point cloud layers. |
|
Default legend implementation for raster layers. |
|
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)
- abstract 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:
- 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]
- flags(self) Qgis.MapLayerLegendFlags[source]¶
Returns flags associated with the legend.
See also
See also
Added in version 4.0.
- Return type:
- 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.
- virtual readXml(self, elem: QDomElement, context: QgsReadWriteContext)[source]¶
Reads configuration from a DOM element previously written by
writeXml()Added in version 3.2.
- Parameters:
elem (QDomElement)
context (QgsReadWriteContext)
- setFlag(self, flag: Qgis.MapLayerLegendFlag, on: bool = True)[source]¶
Enables or disables a particular
flag(other flags are not affected).See also
See also
Added in version 4.0.
- Parameters:
flag (Qgis.MapLayerLegendFlag)
on (bool = True)
- setFlags(self, flags: Qgis.MapLayerLegendFlags | Qgis.MapLayerLegendFlag)[source]¶
Sets the
flagsassociated with the legend.See also
See also
Added in version 4.0.
- Parameters:
flags (Union[Qgis.MapLayerLegendFlags, Qgis.MapLayerLegendFlag])
- virtual 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:
doc (QDomDocument)
context (QgsReadWriteContext)
- Return type:
QDomElement