Class: QgsSymbolLegendNode¶
- class qgis.core.QgsSymbolLegendNode(nodeLayer: QgsLayerTreeLayer, item: QgsLegendSymbolItem, parent: QObject = None)¶
Bases:
QgsLayerTreeModelLegendNode
Constructor for QgsSymbolLegendNode.
- Parameters
nodeLayer – layer node
item – the legend symbol item
parent – attach a parent QObject to the legend node.
Implementation of legend node interface for displaying preview of vector symbols and their labels and allowing interaction with the symbol / renderer.
Methods
Returns a temporary context or
None
if legendMapViewData are not validReturns the node’s custom symbol.
- param role
- param settings
Evaluates and returns the text label of the current node
- param settings
- rtype
Qt.ItemFlags
New in version 2.10.
- param scale
Calculates the minimum icon size to prevent cropping.
Returns the symbol patch shape to use when rendering the legend node symbol.
Sets the node’s custom
symbol
.- param value
- param embedded
Set the icon size
Sets the symbol patch
shape
to use when rendering the legend node symbol.Sets the
symbol
to be used by the legend node.Sets label of text to be shown on top of the symbol.
Sets format of text to be shown on top of the symbol.
- param userLabel
Returns the symbol used by the legend node.
Label of the symbol, user defined label will be used, otherwise will default to the label made by QGIS.
Returns label of text to be shown on top of the symbol.
Returns text format of the label to be shown on top of the symbol.
Attributes
- MAXIMUM_SIZE = -1.0¶
- MINIMUM_SIZE = -1.0¶
- childEvent(self, QChildEvent)¶
- connectNotify(self, QMetaMethod)¶
- createTemporaryRenderContext(self) → QgsRenderContext¶
Returns a temporary context or
None
if legendMapViewData are not valid
- customEvent(self, QEvent)¶
- customSymbol(self) → QgsSymbol¶
Returns the node’s custom symbol.
If a non-
None
value is returned, then this symbol will be used for rendering the legend node instead of the defaultsymbol()
.See also
New in version 3.14.
- Return type
- data(self, role: int) → Any¶
- Parameters
role (int) –
- Return type
Any
- disconnectNotify(self, QMetaMethod)¶
- drawSymbol(self, settings: QgsLegendSettings, ctx: QgsLayerTreeModelLegendNode.ItemContext, itemHeight: float) → QSizeF¶
- Parameters
settings (QgsLegendSettings) –
itemHeight (float) –
- 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()) – extraQgsExpressionContext
to use for evaluating the expressionlabel (str = '') – text to evaluate instead of the layer layertree string
New in version 3.10.
- Return type
str
- exportSymbolToJson(self, settings: QgsLegendSettings, context: QgsRenderContext) → Dict[str, QJsonValue]¶
- Parameters
settings (QgsLegendSettings) –
context (QgsRenderContext) –
- Return type
Dict[str, QJsonValue]
- 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(self, QMetaMethod) → bool¶
- 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 ofminimumIconSize()
.New in version 2.18.
- Return type
QSize
- patchShape(self) → QgsLegendPatchShape¶
Returns the symbol patch shape to use when rendering the legend node symbol.
See also
New in version 3.14.
- Return type
- receivers(self, PYQT_SIGNAL) → int¶
- sender(self) → QObject¶
- senderSignalIndex(self) → int¶
- setCustomSymbol(self, symbol: QgsSymbol)¶
Sets the node’s custom
symbol
.If a non-
None
value is set, then this symbol will be used for rendering the legend node instead of the defaultsymbol()
.Ownership of
symbol
is transferred.See also
New in version 3.14.
- Parameters
symbol (QgsSymbol) –
- 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) –
- setPatchShape(self, shape: QgsLegendPatchShape)¶
Sets the symbol patch
shape
to use when rendering the legend node symbol.See also
New in version 3.14.
- Parameters
shape (QgsLegendPatchShape) –
- 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
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
New in version 2.14.
- Return type
- 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
- timerEvent(self, QTimerEvent)¶