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.

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.

dataDefinedSizeLegendSettings(self) → QgsDataDefinedSizeLegend

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

New in version 3.0.

Return type

QgsDataDefinedSizeLegend

isCheckable(self) → bool

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

Return type

bool

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)

Parameters

scale (float) –

Return type

bool

label(self) → str

Returns text label

Return type

str

legacyRuleKey(self) → QgsSymbol

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

Return type

QgsSymbol

level(self) → int

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

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

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

Return type

str

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

Return type

int

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

Return type

int

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.

Parameters

settings (QgsDataDefinedSizeLegend) –

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()

Parameters

s (QgsSymbol) –

symbol(self) → QgsSymbol

Returns associated symbol. May be None.

Return type

QgsSymbol