Class: QgsLegendSymbolItem¶
The class stores information about one class/rule of a vector layer renderer in a unified way that can be used by legend model for rendering of legend.
See also
Methods
Returns extra information for data-defined size legend rendering.  | 
|
Returns whether the item is user-checkable - whether renderer supports enabling/disabling it  | 
|
Determine whether given scale is within the scale range.  | 
|
Returns text label  | 
|
Used for older code that identifies legend entries from symbol pointer within renderer  | 
|
Indentation level that tells how deep the item is in a hierarchy of items.  | 
|
Key of the parent legend node.  | 
|
Returns unique identifier of the rule for identification of the item within renderer  | 
|
Max scale denominator of the scale range.  | 
|
Min scale denominator of the scale range.  | 
|
Sets extra information about data-defined size.  | 
|
Sets the symbol of the item.  | 
|
Adds a key - value pair to the item's user data.  | 
|
Returns associated symbol.  | 
|
Retrieves the item's user data with the specified key.  | 
- class qgis.core.QgsLegendSymbolItem[source]¶
 Bases:
object- __init__()
 
- __init__(symbol: QgsSymbol | None, label: str | None, ruleKey: str | None, checkable: bool = False, scaleMinDenom: int = -1, scaleMaxDenom: int = -1, level: int = 0, parentRuleKey: str | None = '')
 Construct item. Does not take ownership of symbol (makes internal clone)
- Parameters:
 symbol (Optional[QgsSymbol])
label (Optional[str])
ruleKey (Optional[str])
checkable (bool = False)
scaleMinDenom (int = -1)
scaleMaxDenom (int = -1)
level (int = 0)
parentRuleKey (Optional[str] = '')
- __init__(other: QgsLegendSymbolItem)
 - Parameters:
 other (QgsLegendSymbolItem)
- dataDefinedSizeLegendSettings(self) QgsDataDefinedSizeLegend | None[source]¶
 Returns extra information for data-defined size legend rendering. Normally it returns
None.- Return type:
 Optional[QgsDataDefinedSizeLegend]
- isCheckable(self) bool[source]¶
 Returns whether the item is user-checkable - whether renderer supports enabling/disabling it
- Return type:
 bool
- isScaleOK(self, scale: float) bool[source]¶
 Determine whether given scale is within the scale range. Returns
Trueif scale or scale range is invalid (value <= 0)- Parameters:
 scale (float)
- Return type:
 bool
- legacyRuleKey(self) QgsSymbol | None[source]¶
 Used for older code that identifies legend entries from symbol pointer within renderer
- Return type:
 Optional[QgsSymbol]
- level(self) int[source]¶
 Indentation level that tells how deep the item is in a hierarchy of items. For flat lists level is 0
- Return type:
 int
- parentRuleKey(self) str[source]¶
 Key of the parent legend node. For legends with tree hierarchy
Note
Parameter parentRuleKey added in QGIS 2.8
- Return type:
 str
- ruleKey(self) str[source]¶
 Returns unique identifier of the rule for identification of the item within renderer
- Return type:
 str
- scaleMaxDenom(self) int[source]¶
 Max scale denominator of the scale range. For range 1:1000 to 1:2000 this will return 2000. Value <= 0 means the range is unbounded on this side
- Return type:
 int
- scaleMinDenom(self) int[source]¶
 Min scale denominator of the scale range. For range 1:1000 to 1:2000 this will return 1000. Value <= 0 means the range is unbounded on this side
- Return type:
 int
- setDataDefinedSizeLegendSettings(self, settings: QgsDataDefinedSizeLegend | None)[source]¶
 Sets extra information about data-defined size. If set, this item should be converted to
QgsDataDefinedSizeLegendNoderather thanQgsSymbolLegendNodeinstance as usual. PassingNoneremoves any data-defined size legend settings.Takes ownership of the settings object.
- Parameters:
 settings (Optional[QgsDataDefinedSizeLegend])
- setSymbol(self, s: QgsSymbol | None)[source]¶
 Sets the symbol of the item.
Does not take ownership of symbol – an internal clone is made of the symbol.
See also
- Parameters:
 s (Optional[QgsSymbol])
- setUserData(self, key: int, value: Any)[source]¶
 Adds a
key-valuepair to the item’s user data.See also
Added in version 3.38.
- Parameters:
 key (int)
value (Any)
- symbol(self) QgsSymbol | None[source]¶
 Returns associated symbol. May be
None.- Return type:
 Optional[QgsSymbol]