QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
QgsTextBlock Class Reference

Represents a block of text consisting of one or more QgsTextFragment objects. More...

#include <qgstextblock.h>

Public Member Functions

 QgsTextBlock ()=default
 Constructor for an empty text block.
 QgsTextBlock (const QgsTextFragment &fragment)
 Constructor for a QgsTextBlock consisting of a single text fragment.
void append (const QgsTextFragment &fragment)
 Appends a fragment to the block.
void append (QgsTextFragment &&fragment)
 Appends a fragment to the block.
void applyCapitalization (Qgis::Capitalization capitalization)
 Applies a capitalization style to the block's text.
const QgsTextFragmentat (int index) const
 Returns the fragment at the specified index.
const QgsTextBlockFormatblockFormat () const
 Returns the block formatting for the fragment.
void clear ()
 Clears the block, removing all its contents.
bool empty () const
 Returns true if the block is empty.
bool hasBackgrounds () const
 Returns true if the block or any of the fragments in the block have background brushes set.
void insert (int index, const QgsTextFragment &fragment)
 Inserts a fragment into the block, at the specified index.
void insert (int index, QgsTextFragment &&fragment)
 Inserts a fragment into the block, at the specified index.
QgsTextFragmentoperator[] (int index)
 Returns the fragment at the specified index.
void reserve (int count)
 Reserves the specified count of fragments for optimised fragment appending.
void setBlockFormat (const QgsTextBlockFormat &format)
 Sets the block format for the fragment.
int size () const
 Returns the number of fragments in the block.
QString toPlainText () const
 Converts the block to plain text.

Static Public Member Functions

static QgsTextBlock fromPlainText (const QString &text, const QgsTextCharacterFormat &format=QgsTextCharacterFormat())
 Constructor for QgsTextBlock consisting of a plain text, and optional character format.

Detailed Description

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.
Since
QGIS 3.14

Definition at line 37 of file qgstextblock.h.

Constructor & Destructor Documentation

◆ QgsTextBlock() [1/2]

QgsTextBlock::QgsTextBlock ( )
default

Constructor for an empty text block.

◆ QgsTextBlock() [2/2]

QgsTextBlock::QgsTextBlock ( const QgsTextFragment & fragment)
explicit

Constructor for a QgsTextBlock consisting of a single text fragment.

Definition at line 22 of file qgstextblock.cpp.

Member Function Documentation

◆ append() [1/2]

void QgsTextBlock::append ( const QgsTextFragment & fragment)

Appends a fragment to the block.

Definition at line 70 of file qgstextblock.cpp.

◆ append() [2/2]

void QgsTextBlock::append ( QgsTextFragment && fragment)

Appends a fragment to the block.

Definition at line 75 of file qgstextblock.cpp.

◆ applyCapitalization()

void QgsTextBlock::applyCapitalization ( Qgis::Capitalization capitalization)

Applies a capitalization style to the block's text.

Since
QGIS 3.16

Definition at line 110 of file qgstextblock.cpp.

◆ at()

const QgsTextFragment & QgsTextBlock::at ( int index) const

Returns the fragment at the specified index.

Definition at line 124 of file qgstextblock.cpp.

◆ blockFormat()

const QgsTextBlockFormat & QgsTextBlock::blockFormat ( ) const
inline

Returns the block formatting for the fragment.

See also
setBlockFormat()
Since
QGIS 3.40

Definition at line 145 of file qgstextblock.h.

◆ clear()

void QgsTextBlock::clear ( )

Clears the block, removing all its contents.

Definition at line 90 of file qgstextblock.cpp.

◆ empty()

bool QgsTextBlock::empty ( ) const

Returns true if the block is empty.

Definition at line 95 of file qgstextblock.cpp.

◆ fromPlainText()

QgsTextBlock QgsTextBlock::fromPlainText ( const QString & text,
const QgsTextCharacterFormat & format = QgsTextCharacterFormat() )
static

Constructor for QgsTextBlock consisting of a plain text, and optional character format.

If text contains tab characters they will be appended as separate text fragments within the block, consisting of just the tab character.

Since
QGIS 3.38

Definition at line 27 of file qgstextblock.cpp.

◆ hasBackgrounds()

bool QgsTextBlock::hasBackgrounds ( ) const

Returns true if the block or any of the fragments in the block have background brushes set.

Since
QGIS 3.42

Definition at line 118 of file qgstextblock.cpp.

◆ insert() [1/2]

void QgsTextBlock::insert ( int index,
const QgsTextFragment & fragment )

Inserts a fragment into the block, at the specified index.

Since
QGIS 3.40

Definition at line 80 of file qgstextblock.cpp.

◆ insert() [2/2]

void QgsTextBlock::insert ( int index,
QgsTextFragment && fragment )

Inserts a fragment into the block, at the specified index.

Since
QGIS 3.40

Definition at line 85 of file qgstextblock.cpp.

◆ operator[]()

QgsTextFragment & QgsTextBlock::operator[] ( int index)

Returns the fragment at the specified index.

Definition at line 129 of file qgstextblock.cpp.

◆ reserve()

void QgsTextBlock::reserve ( int count)

Reserves the specified count of fragments for optimised fragment appending.

Since
QGIS 3.40

Definition at line 65 of file qgstextblock.cpp.

◆ setBlockFormat()

void QgsTextBlock::setBlockFormat ( const QgsTextBlockFormat & format)

Sets the block format for the fragment.

See also
blockFormat()
Since
QGIS 3.40

Definition at line 105 of file qgstextblock.cpp.

◆ size()

int QgsTextBlock::size ( ) const

Returns the number of fragments in the block.

Definition at line 100 of file qgstextblock.cpp.

◆ toPlainText()

QString QgsTextBlock::toPlainText ( ) const

Converts the block to plain text.

Since
QGIS 3.16

Definition at line 55 of file qgstextblock.cpp.


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