Class: QgsTextBlock

class qgis.core.QgsTextBlock

Bases: sip.wrapper

Constructor for an empty text block.

QgsTextBlock(fragment: QgsTextFragment) Constructor for a QgsTextBlock consisting of a single text fragment.

QgsTextBlock(QgsTextBlock)

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.

Methods

append

Appends a fragment to the block.

applyCapitalization

Applies a capitalization style to the block’s text.

at

Returns the fragment at the specified index.

clear

Clears the block, removing all its contents.

empty

Returns True if the block is empty.

size

Returns the number of fragments in the block.

toPlainText

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.

Parameters

index (int) –

Return type

QgsTextFragment

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