Class: QgsLegendSymbolItem

class qgis.core.QgsLegendSymbolItem

Bases: sip.wrapper

Constructor for QgsLegendSymbolItem.

QgsLegendSymbolItem(symbol: QgsSymbol, label: str, ruleKey: str, checkable: bool = False, scaleMinDenom: int = -1, scaleMaxDenom: int = -1, level: int = 0, parentRuleKey: str = ‘’) Construct item. Does not take ownership of symbol (makes internal clone)

New in version 2.8.

QgsLegendSymbolItem(other: 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.

New in version 2.6: Enums

Methods

dataDefinedSizeLegendSettings Returns extra information for data-defined size legend rendering.
isCheckable Returns whether the item is user-checkable - whether renderer supports enabling/disabling it
isScaleOK Determine whether given scale is within the scale range.
label Returns text label
legacyRuleKey Used for older code that identifies legend entries from symbol pointer within renderer
level Indentation level that tells how deep the item is in a hierarchy of items.
parentRuleKey Key of the parent legend node.
ruleKey Returns unique identifier of the rule for identification of the item within renderer
scaleMaxDenom Max scale denominator of the scale range.
scaleMinDenom Min scale denominator of the scale range.
setDataDefinedSizeLegendSettings Sets extra information about data-defined size.
setSymbol Sets the symbol of the item.
symbol Returns associated symbol.

Signals

Attributes

dataDefinedSizeLegendSettings(self) → QgsDataDefinedSizeLegend

Returns extra information for data-defined size legend rendering. Normally it returns None.

New in version 3.0.

isCheckable(self) → bool

Returns whether the item is user-checkable - whether renderer supports enabling/disabling it

isScaleOK(self, scale: float) → bool

Determine whether given scale is within the scale range. Returns True if scale or scale range is invalid (value <= 0)

label(self) → str

Returns text label

legacyRuleKey(self) → QgsSymbol

Used for older code that identifies legend entries from symbol pointer within renderer

level(self) → int

Indentation level that tells how deep the item is in a hierarchy of items. For flat lists level is 0

parentRuleKey(self) → str

Key of the parent legend node. For legends with tree hierarchy

Note

Parameter parentRuleKey added in QGIS 2.8

ruleKey(self) → str

Returns unique identifier of the rule for identification of the item within renderer

scaleMaxDenom(self) → int

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

scaleMinDenom(self) → int

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

setDataDefinedSizeLegendSettings(self, settings: QgsDataDefinedSizeLegend)

Sets extra information about data-defined size. If set, this item should be converted to QgsDataDefinedSizeLegendNode rather than QgsSymbolLegendNode instance as usual. Passing None removes any data-defined size legend settings.

Takes ownership of the settings object.

New in version 3.0.

setSymbol(self, s: QgsSymbol)

Sets the symbol of the item.

Does not take ownership of symbol – an internal clone is made of the symbol.

See also

symbol()

symbol(self) → QgsSymbol

Returns associated symbol. May be null.