QGIS API Documentation 3.43.0-Master (ebb4087afc0)
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
QgsLegendStyle Class Reference

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

#include <qgslegendstyle.h>

Public Types

enum  Side { Top = 0 , Bottom = 1 , Left = 2 , Right = 3 }
 Margin sides. More...
 

Public Member Functions

 QgsLegendStyle ()
 
Qt::Alignment alignment () const
 Returns the alignment for the legend component.
 
Q_DECL_DEPRECATED QFont font () const
 Returns the font used for rendering this legend component.
 
double indent () const
 Returns the indent (in mm) of a group or subgroup.
 
double margin (Side side) const
 Returns the margin (in mm) for the specified side of the component.
 
void readXml (const QDomElement &elem, const QDomDocument &doc, const QgsReadWriteContext &context=QgsReadWriteContext())
 Reads the component's style definition from an XML element.
 
void setAlignment (Qt::Alignment alignment)
 Sets the alignment for the legend component.
 
Q_DECL_DEPRECATED void setFont (const QFont &font)
 Sets the font used for rendering this legend component.
 
void setIndent (double indent)
 Sets the indent (in mm) of a group or subgroup.
 
void setMargin (double margin)
 Sets all margin sides to the same margin size (in mm).
 
void setMargin (Side side, double margin)
 Sets the margin (in mm) for the specified side of the component.
 
void setTextFormat (const QgsTextFormat &format)
 Sets the text format used for rendering this legend component.
 
QgsTextFormattextFormat ()
 Returns the text format used for rendering this legend component.
 
QgsTextFormat textFormat () const
 Returns the text format used for rendering this legend component.
 
void updateDataDefinedProperties (QgsRenderContext &context)
 Updates any data-defined properties in the style, using the specified render context.
 
void writeXml (const QString &name, QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context=QgsReadWriteContext()) const
 Writes the component's style definition to an XML element.
 

Static Public Member Functions

static Qgis::LegendComponent styleFromName (const QString &styleName)
 Returns the style from name string.
 
static QString styleLabel (Qgis::LegendComponent s)
 Returns a translated string representing a style component, for use in UI.
 
static QString styleName (Qgis::LegendComponent s)
 Returns the name for a style component as a string.
 

Detailed Description

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

Definition at line 36 of file qgslegendstyle.h.

Member Enumeration Documentation

◆ Side

Margin sides.

Enumerator
Top 

Top side.

Bottom 

Bottom side.

Left 

Left side.

Right 

Right side.

Definition at line 43 of file qgslegendstyle.h.

Constructor & Destructor Documentation

◆ QgsLegendStyle()

QgsLegendStyle::QgsLegendStyle ( )

Definition at line 31 of file qgslegendstyle.cpp.

Member Function Documentation

◆ alignment()

Qt::Alignment QgsLegendStyle::alignment ( ) const
inline

Returns the alignment for the legend component.

See also
setAlignment()
Since
QGIS 3.10

Definition at line 118 of file qgslegendstyle.h.

◆ font()

Q_DECL_DEPRECATED QFont QgsLegendStyle::font ( ) const
inline

Returns the font used for rendering this legend component.

See also
setFont()
Deprecated:
QGIS 3.40. Use textFormat() instead.

Definition at line 58 of file qgslegendstyle.h.

◆ indent()

double QgsLegendStyle::indent ( ) const
inline

Returns the indent (in mm) of a group or subgroup.

See also
indent()
Since
QGIS 3.22

Definition at line 134 of file qgslegendstyle.h.

◆ margin()

double QgsLegendStyle::margin ( Side  side) const
inline

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

Definition at line 95 of file qgslegendstyle.h.

◆ readXml()

void QgsLegendStyle::readXml ( const QDomElement &  elem,
const QDomDocument &  doc,
const QgsReadWriteContext context = QgsReadWriteContext() 
)

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

See also
writeXml()

Definition at line 84 of file qgslegendstyle.cpp.

◆ setAlignment()

void QgsLegendStyle::setAlignment ( Qt::Alignment  alignment)
inline

Sets the alignment for the legend component.

See also
alignment()
Since
QGIS 3.10

Definition at line 126 of file qgslegendstyle.h.

◆ setFont()

void QgsLegendStyle::setFont ( const QFont &  font)

Sets the font used for rendering this legend component.

See also
font()
Deprecated:
QGIS 3.40. Use setTextFormat() instead.

Definition at line 35 of file qgslegendstyle.cpp.

◆ setIndent()

void QgsLegendStyle::setIndent ( double  indent)
inline

Sets the indent (in mm) of a group or subgroup.

See also
indent()
Since
QGIS 3.22

Definition at line 142 of file qgslegendstyle.h.

◆ setMargin() [1/2]

void QgsLegendStyle::setMargin ( double  margin)

Sets all margin sides to the same margin size (in mm).

See also
margin()

Definition at line 50 of file qgslegendstyle.cpp.

◆ setMargin() [2/2]

void QgsLegendStyle::setMargin ( Side  side,
double  margin 
)
inline

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

Definition at line 104 of file qgslegendstyle.h.

◆ setTextFormat()

void QgsLegendStyle::setTextFormat ( const QgsTextFormat format)
inline

Sets the text format used for rendering this legend component.

See also
textFormat()
Since
QGIS 3.30

Definition at line 86 of file qgslegendstyle.h.

◆ styleFromName()

Qgis::LegendComponent QgsLegendStyle::styleFromName ( const QString &  styleName)
static

Returns the style from name string.

See also
styleName()

Definition at line 143 of file qgslegendstyle.cpp.

◆ styleLabel()

QString QgsLegendStyle::styleLabel ( Qgis::LegendComponent  s)
static

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

See also
styleName()

Definition at line 160 of file qgslegendstyle.cpp.

◆ styleName()

QString QgsLegendStyle::styleName ( Qgis::LegendComponent  s)
static

Returns the name for a style component as a string.

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

See also
styleFromName()
styleLabel()

Definition at line 121 of file qgslegendstyle.cpp.

◆ textFormat() [1/2]

QgsTextFormat & QgsLegendStyle::textFormat ( )
inline

Returns the text format used for rendering this legend component.

See also
setTextFormat()
Since
QGIS 3.30

Definition at line 72 of file qgslegendstyle.h.

◆ textFormat() [2/2]

QgsTextFormat QgsLegendStyle::textFormat ( ) const
inline

Returns the text format used for rendering this legend component.

See also
setTextFormat()
Since
QGIS 3.30

Definition at line 79 of file qgslegendstyle.h.

◆ updateDataDefinedProperties()

void QgsLegendStyle::updateDataDefinedProperties ( QgsRenderContext context)

Updates any data-defined properties in the style, using the specified render context.

Since
QGIS 3.42

Definition at line 114 of file qgslegendstyle.cpp.

◆ writeXml()

void QgsLegendStyle::writeXml ( const QString &  name,
QDomElement &  elem,
QDomDocument &  doc,
const QgsReadWriteContext context = QgsReadWriteContext() 
) const

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

See also
readXml()

Definition at line 58 of file qgslegendstyle.cpp.


The documentation for this class was generated from the following files: