Class: QgsLegendSettings¶
-
class
qgis.core.
QgsLegendSettings
¶ Bases:
sip.wrapper
The
QgsLegendSettings
class stores the appearance and layout settings for legend drawing withQgsLegendRenderer
. The content of the legend is given inQgsLegendModel
class.Methods
- rtype
float
- rtype
int
- rtype
float
- rtype
int
Returns whether a stroke will be drawn around raster symbol items.
Draws Text.
- rtype
bool
Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE
- rtype
QColor
Returns the font descent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE
Returns the font height of a character in millimeters
Returns layer font color, defaults to fontColor()
- rtype
float
Returns the legend map scale.
Returns the factor of map units per pixel for symbols with size given in map units calculated by mDpi and mMmPerMapUnit
- rtype
float
Calculates font to from point size to pixel size
Returns the stroke color for the stroke drawn around raster symbol items.
Returns the stroke width (in millimeters) for the stroke drawn around raster symbol items.
Returns a font where size is in pixel and font size is upscaled with FONT_WORKAROUND_SCALE
- param s
- param c
- param s
- param dpi
Sets whether a stroke will be drawn around raster symbol items.
- param s
- param c
Sets layer font color to
fontColor
Overrides fontColor()- param s
Sets the legend map
scale
.Sets the mMmPerMapUnit calculated by
mapUnitsPerPixel
mostly taken from the map settings.- param mmPerMapUnit
Sets the stroke color for the stroke drawn around raster symbol items.
Sets the stroke width for the stroke drawn around raster symbol items.
- param s
- param s
- param s
- param t
Sets the alignment of the legend title
- param use
- param s
- param t
- rtype
bool
Splits a string using the wrap char taking into account handling empty wrap char which means no wrapping
Returns style
- rtype
QSizeF
Returns the font width in millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE
- rtype
str
Returns the alignment of the legend title
- rtype
bool
- rtype
QSizeF
- rtype
str
-
boxSpace
(self) → float¶ - Return type
float
-
columnCount
(self) → int¶ - Return type
int
-
columnSpace
(self) → float¶ - Return type
float
-
dpi
(self) → int¶ - Return type
int
-
drawRasterStroke
(self) → bool¶ Returns whether a stroke will be drawn around raster symbol items.
See also
See also
See also
New in version 2.12.
- Return type
bool
-
drawText
(self, p: QPainter, x: float, y: float, text: str, font: QFont)¶ Draws Text. Takes care about all the composer specific issues (calculation to pixel, scaling of font and painter to work around the Qt font bug)
drawText(self, p: QPainter, rect: QRectF, text: str, font: QFont, halignment: Qt.AlignmentFlag = Qt.AlignLeft, valignment: Qt.AlignmentFlag = Qt.AlignTop, flags: int = Qt.TextWordWrap) Like the above, but with a rectangle for multiline text
- Parameters
p (QPainter) – painter to use
rect – rectangle to draw into
text (str) – text to draw
font (QFont) – font to use
halignment – optional horizontal alignment
valignment – optional vertical alignment
flags – allows for passing Qt.TextFlags to control appearance of rendered text
x (float) –
y (float) –
-
equalColumnWidth
(self) → bool¶ - Return type
bool
-
fontAscentMillimeters
(self, font: QFont) → float¶ Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE
- Parameters
font (QFont) –
- Return type
float
-
fontColor
(self) → QColor¶ - Return type
QColor
-
fontDescentMillimeters
(self, font: QFont) → float¶ Returns the font descent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE
- Parameters
font (QFont) –
- Return type
float
-
fontHeightCharacterMM
(self, font: QFont, c: str) → float¶ Returns the font height of a character in millimeters
- Parameters
font (QFont) –
c (str) –
- Return type
float
-
layerFontColor
(self) → QColor¶ Returns layer font color, defaults to fontColor()
See also
See also
New in version 3.4.7.
- Return type
QColor
-
lineSpacing
(self) → float¶ - Return type
float
-
mapScale
(self) → float¶ Returns the legend map scale. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
See also
- Return type
float
-
mapUnitsPerPixel
(self) → float¶ Returns the factor of map units per pixel for symbols with size given in map units calculated by mDpi and mMmPerMapUnit
See also
New in version 3.4.
- Return type
float
-
mmPerMapUnit
(self) → float¶ - Return type
float
-
pixelFontSize
(self, pointSize: float) → float¶ Calculates font to from point size to pixel size
- Parameters
pointSize (float) –
- Return type
float
-
rasterStrokeColor
(self) → QColor¶ Returns the stroke color for the stroke drawn around raster symbol items. The stroke is only drawn if drawRasterStroke() is true.
See also
See also
See also
New in version 2.12.
- Return type
QColor
-
rasterStrokeWidth
(self) → float¶ Returns the stroke width (in millimeters) for the stroke drawn around raster symbol items. The stroke is only drawn if drawRasterStroke() is true.
See also
See also
See also
New in version 2.12.
- Return type
float
-
scaledFontPixelSize
(self, font: QFont) → QFont¶ Returns a font where size is in pixel and font size is upscaled with FONT_WORKAROUND_SCALE
- Parameters
font (QFont) –
- Return type
QFont
-
setBoxSpace
(self, s: float)¶ - Parameters
s (float) –
-
setColumnCount
(self, c: int)¶ - Parameters
c (int) –
-
setColumnSpace
(self, s: float)¶ - Parameters
s (float) –
-
setDpi
(self, dpi: int)¶ - Parameters
dpi (int) –
-
setDrawRasterStroke
(self, enabled: bool)¶ Sets whether a stroke will be drawn around raster symbol items.
- Parameters
enabled (bool) – set to true to draw borders
See also
See also
See also
New in version 2.12.
-
setEqualColumnWidth
(self, s: bool)¶ - Parameters
s (bool) –
-
setFontColor
(self, c: Union[QColor, Qt.GlobalColor, QGradient])¶ - Parameters
c (Union[QColor) –
-
setLayerFontColor
(self, fontColor: Union[QColor, Qt.GlobalColor, QGradient])¶ Sets layer font color to
fontColor
Overrides fontColor()See also
See also
New in version 3.4.7.
- Parameters
fontColor (Union[QColor) –
-
setLineSpacing
(self, s: float)¶ - Parameters
s (float) –
-
setMapScale
(self, scale: float)¶ Sets the legend map
scale
. Thescale
value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.See also
- Parameters
scale (float) –
-
setMapUnitsPerPixel
(self, mapUnitsPerPixel: float)¶ Sets the mMmPerMapUnit calculated by
mapUnitsPerPixel
mostly taken from the map settings.See also
New in version 3.4.
- Parameters
mapUnitsPerPixel (float) –
-
setMmPerMapUnit
(self, mmPerMapUnit: float)¶ - Parameters
mmPerMapUnit (float) –
-
setRasterStrokeColor
(self, color: Union[QColor, Qt.GlobalColor, QGradient])¶ Sets the stroke color for the stroke drawn around raster symbol items. The stroke is only drawn if drawRasterStroke() is true.
- Parameters
color (Union[QColor) – stroke color
See also
See also
See also
New in version 2.12.
-
setRasterStrokeWidth
(self, width: float)¶ Sets the stroke width for the stroke drawn around raster symbol items. The stroke is only drawn if drawRasterStroke() is true.
- Parameters
width (float) – stroke width in millimeters
See also
See also
See also
New in version 2.12.
-
setSplitLayer
(self, s: bool)¶ - Parameters
s (bool) –
-
setStyle
(self, s: QgsLegendStyle.Style, style: QgsLegendStyle)¶ - Parameters
s (QgsLegendStyle.Style) –
style (QgsLegendStyle) –
-
setSymbolSize
(self, s: QSizeF)¶ - Parameters
s (QSizeF) –
-
setTitle
(self, t: str)¶ - Parameters
t (str) –
-
setTitleAlignment
(self, alignment: Qt.AlignmentFlag)¶ Sets the alignment of the legend title
- Parameters
alignment (Qt.AlignmentFlag) – Text alignment for drawing the legend title
See also
-
setUseAdvancedEffects
(self, use: bool)¶ - Parameters
use (bool) –
-
setWmsLegendSize
(self, s: QSizeF)¶ - Parameters
s (QSizeF) –
-
setWrapChar
(self, t: str)¶ - Parameters
t (str) –
-
splitLayer
(self) → bool¶ - Return type
bool
-
splitStringForWrapping
(self, stringToSplt: str) → List[str]¶ Splits a string using the wrap char taking into account handling empty wrap char which means no wrapping
- Parameters
stringToSplt (str) –
- Return type
List[str]
-
style
(self, s: QgsLegendStyle.Style) → QgsLegendStyle¶ Returns style
- Parameters
s (QgsLegendStyle.Style) –
- Return type
-
symbolSize
(self) → QSizeF¶ - Return type
QSizeF
-
textWidthMillimeters
(self, font: QFont, text: str) → float¶ Returns the font width in millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE
- Parameters
font (QFont) –
text (str) –
- Return type
float
-
title
(self) → str¶ - Return type
str
-
titleAlignment
(self) → Qt.AlignmentFlag¶ Returns the alignment of the legend title
- Return type
Qt.AlignmentFlag
- Returns
Qt.AlignmentFlag for the legend title
See also
-
useAdvancedEffects
(self) → bool¶ - Return type
bool
-
wmsLegendSize
(self) → QSizeF¶ - Return type
QSizeF
-
wrapChar
(self) → str¶ - Return type
str