Class: QgsSymbolLegendNode

class qgis.core.QgsSymbolLegendNode(nodeLayer: QgsLayerTreeLayer, item: QgsLegendSymbolItem, parent: QObject = None)

Bases: QgsLayerTreeModelLegendNode

Constructor for QgsSymbolLegendNode.

Parameters

Implementation of legend node interface for displaying preview of vector symbols and their labels and allowing interaction with the symbol / renderer.

Methods

checkAllItems

Checks all items belonging to the same layer as this node.

childEvent

connectNotify

createTemporaryRenderContext

customEvent

data

param role

disconnectNotify

drawSymbol

param settings

evaluateLabel

Evaluates and returns the text label of the current node

exportSymbolToJson

param settings

flags

rtype

Qt.ItemFlags

iconSize

New in version 2.10.

invalidateMapBasedData

isScaleOK

param scale

isSignalConnected

minimumIconSize

Calculates the minimum icon size to prevent cropping.

receivers

sender

senderSignalIndex

setData

param value

setEmbeddedInParent

param embedded

setIconSize

Set the icon size

setSymbol

Sets the symbol to be used by the legend node.

setTextOnSymbolLabel

Sets label of text to be shown on top of the symbol.

setTextOnSymbolTextFormat

Sets format of text to be shown on top of the symbol.

setUserLabel

param userLabel

symbol

Returns the symbol used by the legend node.

symbolLabel

Label of the symbol, user defined label will be used, otherwise will default to the label made by QGIS.

textOnSymbolLabel

Returns label of text to be shown on top of the symbol.

textOnSymbolTextFormat

Returns text format of the label to be shown on top of the symbol.

timerEvent

toggleAllItems

Toggle all items belonging to the same layer as this node.

uncheckAllItems

Unchecks all items belonging to the same layer as this node.

checkAllItems(self)

Checks all items belonging to the same layer as this node.

See also

toggleAllItems()

New in version 2.14.

childEvent()
connectNotify()
createTemporaryRenderContext()
customEvent()
data(self, role: int) → Any
Parameters

role (int) –

Return type

Any

disconnectNotify()
drawSymbol(self, settings: QgsLegendSettings, ctx: QgsLayerTreeModelLegendNode.ItemContext, itemHeight: float) → QSizeF
Parameters
Return type

QSizeF

evaluateLabel(self, context: QgsExpressionContext = QgsExpressionContext(), label: str = '') → str

Evaluates and returns the text label of the current node

Parameters
  • context (QgsExpressionContext = QgsExpressionContext()) – extra QgsExpressionContext to use for evaluating the expression

  • label (str = '') – text to evaluate instead of the layer layertree string

New in version 3.10.

Return type

str

exportSymbolToJson(self, settings: QgsLegendSettings, context: QgsRenderContext, json: Dict[str, Union[QJsonValue, QJsonValue.Type, Iterable[QJsonValue], bool, int, float, str]])
Parameters
flags(self) → Qt.ItemFlags
Return type

Qt.ItemFlags

iconSize(self) → QSize

New in version 2.10.

Return type

QSize

invalidateMapBasedData(self)
isScaleOK(self, scale: float) → bool
Parameters

scale (float) –

Return type

bool

isSignalConnected()
minimumIconSize(self) → QSize

Calculates the minimum icon size to prevent cropping. When evaluating the size for multiple icons it is more efficient to create a single render context in advance and use the variant which accepts a QgsRenderContext argument.

New in version 2.10.

minimumIconSize(self, context: QgsRenderContext) -> QSize Calculates the minimum icon size to prevent cropping. When evaluating the size for multiple icons it is more efficient to create a single render context in advance and call this method instead of minimumIconSize().

New in version 2.18.

Return type

QSize

receivers()
sender()
senderSignalIndex()
setData(self, value: Any, role: int) → bool
Parameters
  • value (Any) –

  • role (int) –

Return type

bool

setEmbeddedInParent(self, embedded: bool)
Parameters

embedded (bool) –

setIconSize(self, sz: QSize)

Set the icon size

New in version 2.10.

Parameters

sz (QSize) –

setSymbol(self, symbol: QgsSymbol)

Sets the symbol to be used by the legend node. The symbol change is also propagated to the associated vector layer’s renderer.

Parameters

symbol (QgsSymbol) – new symbol for node. Ownership is transferred.

See also

symbol()

New in version 2.14.

setTextOnSymbolLabel(self, label: str)

Sets label of text to be shown on top of the symbol.

New in version 3.2.

Parameters

label (str) –

setTextOnSymbolTextFormat(self, format: QgsTextFormat)

Sets format of text to be shown on top of the symbol.

New in version 3.2.

Parameters

format (QgsTextFormat) –

setUserLabel(self, userLabel: str)
Parameters

userLabel (str) –

symbol(self) → QgsSymbol

Returns the symbol used by the legend node.

See also

setSymbol()

New in version 2.14.

Return type

QgsSymbol

symbolLabel(self) → str

Label of the symbol, user defined label will be used, otherwise will default to the label made by QGIS.

New in version 3.10.

Return type

str

textOnSymbolLabel(self) → str

Returns label of text to be shown on top of the symbol.

New in version 3.2.

Return type

str

textOnSymbolTextFormat(self) → QgsTextFormat

Returns text format of the label to be shown on top of the symbol.

New in version 3.2.

Return type

QgsTextFormat

timerEvent()
toggleAllItems(self)

Toggle all items belonging to the same layer as this node.

See also

checkAllItems()

New in version 3.6.

uncheckAllItems(self)

Unchecks all items belonging to the same layer as this node.

See also

checkAllItems()

See also

toggleAllItems()

New in version 2.14.