Class: QgsMapLayerLegendUtils

class qgis.core.QgsMapLayerLegendUtils

Bases: sip.wrapper

Miscellaneous utility functions for handling of map layer legend

Methods

applyLayerNodeProperties

update according to layer node’s custom properties (order of items, user labels for items)

hasLegendNodeOrder

param nodeLayer

hasLegendNodeUserLabel

param nodeLayer

legendNodeColumnBreak

Returns whether a forced column break should occur before the node.

legendNodeCustomSymbol

Returns the custom legend symbol for the legend node belonging to nodeLayer at the specified originalIndex.

legendNodeOrder

param nodeLayer

legendNodePatchShape

Returns the legend patch shape for the legend node belonging to nodeLayer at the specified originalIndex.

legendNodeSymbolSize

Returns the legend node symbol size for the legend node belonging to nodeLayer at the specified originalIndex.

legendNodeUserLabel

param nodeLayer

setLegendNodeColumnBreak

Sets whether a forced column break should occur before the node.

setLegendNodeCustomSymbol

Sets a custom legend symbol size for the legend node belonging to nodeLayer at the specified originalIndex.

setLegendNodeOrder

param nodeLayer

setLegendNodePatchShape

Sets the legend patch shape for the legend node belonging to nodeLayer at the specified originalIndex.

setLegendNodeSymbolSize

Sets the legend symbol size for the legend node belonging to nodeLayer at the specified originalIndex.

setLegendNodeUserLabel

param nodeLayer

applyLayerNodeProperties(nodeLayer: QgsLayerTreeLayer, nodes: Iterable[QgsLayerTreeModelLegendNode])

update according to layer node’s custom properties (order of items, user labels for items)

Parameters
hasLegendNodeOrder(nodeLayer: QgsLayerTreeLayer)bool
Parameters

nodeLayer (QgsLayerTreeLayer) –

Return type

bool

hasLegendNodeUserLabel(nodeLayer: QgsLayerTreeLayer, originalIndex: int)bool
Parameters
Return type

bool

legendNodeColumnBreak(nodeLayer: QgsLayerTreeLayer, originalIndex: int)bool

Returns whether a forced column break should occur before the node.

New in version 3.14.

Parameters
Return type

bool

legendNodeCustomSymbol(nodeLayer: QgsLayerTreeLayer, originalIndex: int)QgsSymbol

Returns the custom legend symbol for the legend node belonging to nodeLayer at the specified originalIndex.

If the symbol is non-None, it will be used in place of the default symbol when rendering the legend node.

Caller takes ownership of the returned symbol.

New in version 3.14.

Parameters
Return type

QgsSymbol

legendNodeOrder(nodeLayer: QgsLayerTreeLayer)List[int]
Parameters

nodeLayer (QgsLayerTreeLayer) –

Return type

List[int]

legendNodePatchShape(nodeLayer: QgsLayerTreeLayer, originalIndex: int)QgsLegendPatchShape

Returns the legend patch shape for the legend node belonging to nodeLayer at the specified originalIndex.

New in version 3.14.

Parameters
Return type

QgsLegendPatchShape

legendNodeSymbolSize(nodeLayer: QgsLayerTreeLayer, originalIndex: int)QSizeF

Returns the legend node symbol size for the legend node belonging to nodeLayer at the specified originalIndex.

If either the width or height are non-zero, they will be used when rendering the legend node instead of the default symbol width or height from QgsLegendSettings.

New in version 3.14.

Parameters
Return type

QSizeF

legendNodeUserLabel(nodeLayer: QgsLayerTreeLayer, originalIndex: int)str
Parameters
Return type

str

setLegendNodeColumnBreak(nodeLayer: QgsLayerTreeLayer, originalIndex: int, columnBreakBeforeNode: bool)

Sets whether a forced column break should occur before the node.

New in version 3.14.

Parameters
  • nodeLayer (QgsLayerTreeLayer) –

  • originalIndex (int) –

  • columnBreakBeforeNode (bool) –

setLegendNodeCustomSymbol(nodeLayer: QgsLayerTreeLayer, originalIndex: int, symbol: QgsSymbol)

Sets a custom legend symbol size for the legend node belonging to nodeLayer at the specified originalIndex.

If symbol is non-None, it will be used in place of the default symbol when rendering the legend node.

New in version 3.14.

Parameters
setLegendNodeOrder(nodeLayer: QgsLayerTreeLayer, order: Iterable[int])
Parameters
setLegendNodePatchShape(nodeLayer: QgsLayerTreeLayer, originalIndex: int, shape: QgsLegendPatchShape)

Sets the legend patch shape for the legend node belonging to nodeLayer at the specified originalIndex.

New in version 3.14.

Parameters
setLegendNodeSymbolSize(nodeLayer: QgsLayerTreeLayer, originalIndex: int, size: QSizeF)

Sets the legend symbol size for the legend node belonging to nodeLayer at the specified originalIndex.

If either the width or height are non-zero, they will be used when rendering the legend node instead of the default symbol width or height from QgsLegendSettings.

New in version 3.14.

Parameters
setLegendNodeUserLabel(nodeLayer: QgsLayerTreeLayer, originalIndex: int, newLabel: str)
Parameters