Class: QgsTextBlock¶
- class qgis.core.QgsTextBlock¶
Bases:
sip.wrapper
Represents a block of text consisting of one or more
QgsTextFragment
objects.Warning
This API is not considered stable and may change in future QGIS versions.
New in version 3.14.
QgsTextBlock() Constructor for an empty text block.
QgsTextBlock(fragment:
QgsTextFragment
) Constructor for aQgsTextBlock
consisting of a single textfragment
.QgsTextBlock(
QgsTextBlock
)Methods
Appends a
fragment
to the block.Applies a
capitalization
style to the block's text.Returns the fragment at the specified
index
.Clears the block, removing all its contents.
Returns
True
if the block is empty.Returns the number of fragments in the block.
Converts the block to plain text.
- append(self, fragment: QgsTextFragment)¶
Appends a
fragment
to the block.- Parameters
fragment (QgsTextFragment) –
- applyCapitalization(self, capitalization: QgsStringUtils.Capitalization)¶
Applies a
capitalization
style to the block’s text.New in version 3.16.
- Parameters
capitalization (QgsStringUtils.Capitalization) –
- at(self, index: int) QgsTextFragment ¶
Returns the fragment at the specified
index
.:raises KeyError if no fragment exists at the specified index.
- Parameters
index (int) –
- Return type
- clear(self)¶
Clears the block, removing all its contents.
- empty(self) bool ¶
Returns
True
if the block is empty.- Return type
bool
- size(self) int ¶
Returns the number of fragments in the block.
- Return type
int
- toPlainText(self) str ¶
Converts the block to plain text.
New in version 3.16.
- Return type
str