Class: QgsLegendStyle¶
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 specified side of the component.  | 
|
Sets the text format used for rendering this legend component.  | 
|
Returns the text format used for rendering this legend component.  | 
|
Updates any data-defined properties in the style, using the specified render context.  | 
|
Writes the component's style definition to an XML element.  | 
Static Methods
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.  | 
Attributes
- class qgis.core.QgsLegendStyle[source]¶
 Bases:
object- 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[source]¶
 Returns the alignment for the legend component.
See also
Added in version 3.10.
- Return type:
 Qt.Alignment
- font(self) QFont[source]¶
 Returns the font used for rendering this legend component.
See also
Deprecated since version 3.40: Use
textFormat()instead.- Return type:
 QFont
- indent(self) float[source]¶
 Returns the indent (in mm) of a group or subgroup.
See also
Added in version 3.22.
- Return type:
 float
- margin(self, side: QgsLegendStyle.Side) float[source]¶
 Returns the margin (in mm) for the specified
sideof 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())[source]¶
 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)[source]¶
 Sets the alignment for the legend component.
See also
Added in version 3.10.
- Parameters:
 alignment (Union[Qt.Alignment, Qt.AlignmentFlag])
- setFont(self, font: QFont)[source]¶
 Sets the
fontused for rendering this legend component.See also
Deprecated since version 3.40: Use
setTextFormat()instead.- Parameters:
 font (QFont)
- setIndent(self, indent: float)[source]¶
 Sets the indent (in mm) of a group or subgroup.
See also
Added in version 3.22.
- Parameters:
 indent (float)
- setMargin(self, side: QgsLegendStyle.Side, margin: float)[source]¶
 Sets the
margin(in mm) for the specifiedsideof the component.Note
Not all legend components respect all margin side settings!
See also
- Parameters:
 side (QgsLegendStyle.Side)
margin (float)
- setMargin(self, margin: float)[source]
 Sets all margin sides to the same
marginsize (in mm).See also
- Parameters:
 margin (float)
- setTextFormat(self, format: QgsTextFormat)[source]¶
 Sets the text
formatused for rendering this legend component.See also
Added in version 3.30.
- Parameters:
 format (QgsTextFormat)
- static styleFromName(styleName: str | None) QgsLegendStyle.Style[source]¶
 Returns the style from name string.
See also
- Parameters:
 styleName (Optional[str])
- Return type:
 
- static styleLabel(s: QgsLegendStyle.Style) str[source]¶
 Returns a translated string representing a style component, for use in UI.
See also
- Parameters:
 - Return type:
 str
- static styleName(s: QgsLegendStyle.Style) str[source]¶
 Returns the name for a style component as a string.
This is a non-localised version, for internal use.
See also
See also
- Parameters:
 - Return type:
 str
- textFormat(self) QgsTextFormat¶
 Returns the text format used for rendering this legend component.
See also
Added in version 3.30.
- Return type:
 
- updateDataDefinedProperties(self, context: QgsRenderContext)[source]¶
 Updates any data-defined properties in the style, using the specified render
context.Added in version 3.42.
- Parameters:
 context (QgsRenderContext)
- writeXml(self, name: str | None, elem: QDomElement, doc: QDomDocument, context: QgsReadWriteContext = QgsReadWriteContext())[source]¶
 Writes the component’s style definition to an XML element.
See also
- Parameters:
 name (Optional[str])
elem (QDomElement)
doc (QDomDocument)
context (
QgsReadWriteContext= QgsReadWriteContext())