Class: QgsLegendStyle

class qgis.core.QgsLegendStyle

Bases: sip.wrapper

Contains detailed styling information relating to how a layout legend should be rendered.

Enums

Methods

alignment

Returns the alignment for the legend component.

font

Returns the font used for rendering this legend component.

margin

Returns the margin (in mm) for the specified side of the component.

readXml

Reads the component’s style definition from an XML element.

setAlignment

Sets the alignment for the legend component.

setFont

Sets the font used for rendering this legend component.

setMargin

Sets the margin (in mm) for the specified side of the component.

styleFromName

Returns the style from name string.

styleLabel

Returns a translated string representing a style component, for use in UI.

styleName

Returns the name for a style component as a string.

writeXml

Writes the component’s style definition to an XML element.

Signals

Attributes

Bottom

Group

Hidden

Left

Right

Subgroup

Symbol

SymbolLabel

Title

Top

Undefined

Bottom = 1
Group = 3
Hidden = 1
Left = 2
Right = 3
class Side

Bases: int

class Style

Bases: int

Subgroup = 4
Symbol = 5
SymbolLabel = 6
Title = 2
Top = 0
Undefined = 0
alignment(self) → Qt.Alignment

Returns the alignment for the legend component.

See also

setAlignment()

New in version 3.10.

font(self) → QFont

Returns the font used for rendering this legend component.

See also

setFont()

margin(self, side: QgsLegendStyle.Side) → float

Returns the margin (in mm) for the specified side of the component.

Note

Not all legend components respect all margin side settings!

See also

setMargin()

readXml(self, elem: QDomElement, doc: QDomDocument)

Reads the component’s style definition from an XML element.

See also

writeXml()

setAlignment(self, alignment: Union[Qt.Alignment, Qt.AlignmentFlag])

Sets the alignment for the legend component.

See also

alignment()

New in version 3.10.

setFont(self, font: QFont)

Sets the font used for rendering this legend component.

See also

font()

setMargin(self, side: QgsLegendStyle.Side, margin: float)

Sets the margin (in mm) for the specified side of the component.

Note

Not all legend components respect all margin side settings!

See also

margin()

setMargin(self, margin: float) Sets all margin sides to the same margin size (in mm).

See also

margin()

styleFromName(styleName: str) → QgsLegendStyle.Style

Returns the style from name string.

See also

styleName()

styleLabel(s: QgsLegendStyle.Style) → str

Returns a translated string representing a style component, for use in UI.

See also

styleName()

styleName(s: QgsLegendStyle.Style) → str

Returns the name for a style component as a string.

This is a non-localised version, for internal use.

See also

styleFromName()

See also

styleLabel()

writeXml(self, name: str, elem: QDomElement, doc: QDomDocument)

Writes the component’s style definition to an XML element.

See also

readXml()