Class: QgsTextBlockFormat¶
Stores information relating to individual block formatting.
These options encapsulate formatting options which override the default
settings from a QgsTextFormat
for individual text blocks.
Warning
This API is not considered stable and may change in future QGIS versions.
Added in version 3.40.
Enums
Status values for boolean format properties |
Methods
Returns |
|
Returns the format horizontal alignment. |
|
Override all the default/unset properties of the current block format with the settings from another format. |
|
Sets whether the format has an explicit horizontal alignment set. |
|
Sets the format horizontal alignment. |
|
Updates the specified font in place, applying block formatting options which are applicable on a font level when rendered in the given context. |
- class qgis.core.QgsTextBlockFormat[source]¶
Bases:
object
- __init__()
- __init__(format: QTextBlockFormat)
Constructor for QgsTextBlockFormat, based on the specified QTextBlockFormat
format
.- Parameters:
format (QTextBlockFormat)
- __init__(a0: QgsTextBlockFormat)
- Parameters:
a0 (QgsTextBlockFormat)
- class BooleanValue(*values)¶
Bases:
IntEnum
Status values for boolean format properties
NotSet
: Property is not setSetTrue
: Property is set andTrue
SetFalse
: Property is set andFalse
- NotSet = 0¶
- SetFalse = 2¶
- SetTrue = 1¶
- hasHorizontalAlignmentSet(self) bool [source]¶
Returns
True
if the format has an explicit horizontal alignment set.If
False
is returned then the horizontal alignment will be inherited.See also
See also
- Return type:
bool
- horizontalAlignment(self) Qgis.TextHorizontalAlignment [source]¶
Returns the format horizontal alignment.
This property is only respected if
hasHorizontalAlignmentSet()
isTrue
.See also
See also
- Return type:
- overrideWith(self, other: QgsTextBlockFormat)[source]¶
Override all the default/unset properties of the current block format with the settings from another format.
This will replace any default/unset existing settings with the settings from
other
.Any settings which are default/unset in
other
will be left unchanged.- Parameters:
other (QgsTextBlockFormat) – The format to override with.
- setHasHorizontalAlignmentSet(self, set: bool)[source]¶
Sets whether the format has an explicit horizontal alignment
set
.If
set
isFalse
then the horizontal alignment will be inherited.See also
See also
- Parameters:
set (bool)
- setHorizontalAlignment(self, alignment: Qgis.TextHorizontalAlignment)[source]¶
Sets the format horizontal
alignment
.This property is only respected if
hasHorizontalAlignmentSet()
isTrue
.See also
See also
- Parameters:
alignment (Qgis.TextHorizontalAlignment)
- updateFontForFormat(self, font: QFont, context: QgsRenderContext, scaleFactor: float = 1)[source]¶
Updates the specified
font
in place, applying block formatting options which are applicable on a font level when rendered in the givencontext
.The optional
scaleFactor
parameter can specify a font size scaling factor. It is recommended to set this toQgsTextRenderer.calculateScaleFactorForFormat()
and then manually calculations based on the resultant font metrics. Failure to do so will result in poor quality text rendering at small font sizes.- Parameters:
font (QFont)
context (QgsRenderContext)
scaleFactor (float = 1)