Class: QgsLegendStyle¶
- class qgis.core.QgsLegendStyle¶
Bases:
sip.wrapper
Contains detailed styling information relating to how a layout legend should be rendered.
Methods
Returns the alignment for the legend component.
Returns the font used for rendering this legend component.
Returns the indent (in mm) of a group or subgroup.
Returns the margin (in mm) for the specified
side
of the component.Reads the component's style definition from an XML element.
Sets the alignment for the legend component.
Sets the
font
used for rendering this legend component.Sets the indent (in mm) of a group or subgroup.
Sets the
margin
(in mm) for the specifiedside
of the component.Returns the style from name string.
Returns a translated string representing a style component, for use in UI.
Returns the name for a style component as a string.
Writes the component's style definition to an XML element.
Attributes
- 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
New in version 3.10.
- Return type:
Qt.Alignment
- font(self) QFont ¶
Returns the font used for rendering this legend component.
See also
- Return type:
QFont
- indent(self) float ¶
Returns the indent (in mm) of a group or subgroup.
See also
New in version 3.22.
- Return type:
float
- 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
- Parameters:
side (QgsLegendStyle.Side) –
- Return type:
float
- readXml(self, elem: QDomElement, doc: QDomDocument, context: QgsReadWriteContext = QgsReadWriteContext())¶
Reads the component’s style definition from an XML element.
See also
- Parameters:
elem (QDomElement) –
doc (QDomDocument) –
context (
QgsReadWriteContext
= QgsReadWriteContext()) –
- setAlignment(self, alignment: Qt.Alignment | Qt.AlignmentFlag)¶
Sets the alignment for the legend component.
See also
New in version 3.10.
- Parameters:
alignment (Union[Qt.Alignment) –
- setFont(self, font: QFont)¶
Sets the
font
used for rendering this legend component.See also
- Parameters:
font (QFont) –
- setIndent(self, indent: float)¶
Sets the indent (in mm) of a group or subgroup.
See also
New in version 3.22.
- Parameters:
indent (float) –
- setMargin(self, side: QgsLegendStyle.Side, margin: float)¶
Sets the
margin
(in mm) for the specifiedside
of the component.Note
Not all legend components respect all margin side settings!
See also
setMargin(self, margin: float) Sets all margin sides to the same
margin
size (in mm).See also
- Parameters:
side (QgsLegendStyle.Side) –
margin (float) –
- styleFromName(styleName: str) QgsLegendStyle.Style ¶
Returns the style from name string.
See also
- Parameters:
styleName (str) –
- Return type:
- styleLabel(s: QgsLegendStyle.Style) str ¶
Returns a translated string representing a style component, for use in UI.
See also
- Parameters:
s (QgsLegendStyle.Style) –
- Return type:
str
- 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
See also
- Parameters:
s (QgsLegendStyle.Style) –
- Return type:
str
- writeXml(self, name: str, elem: QDomElement, doc: QDomDocument, context: QgsReadWriteContext = QgsReadWriteContext())¶
Writes the component’s style definition to an XML element.
See also
- Parameters:
name (str) –
elem (QDomElement) –
doc (QDomDocument) –
context (
QgsReadWriteContext
= QgsReadWriteContext()) –