Class: QgsAnnotationRectangleTextItem

An annotation item which renders paragraphs of text within a rectangle.

Added in version 3.40.

Class Hierarchy

Inheritance diagram of qgis.core.QgsAnnotationRectangleTextItem

Base classes

QgsAnnotationRectItem

Abstract base class for annotation items which render annotations in a rectangular shape.

QgsAnnotationItem

Abstract base class for annotation items which are drawn with QgsAnnotationLayers.

class qgis.core.QgsAnnotationRectangleTextItem[source]

Bases: QgsAnnotationRectItem

__init__(text: str | None, bounds: QgsRectangle)

Constructor for QgsAnnotationRectangleTextItem, containing the specified text within the specified bounds rectangle.

Parameters:
alignment(self) Qt.Alignment[source]

Returns the text’s alignment relative to the bounds() rectangle.

See also

setAlignment()

Return type:

Qt.Alignment

static create() QgsAnnotationRectangleTextItem | None[source]

Creates a new rectangle text annotation item.

Return type:

Optional[QgsAnnotationRectangleTextItem]

format(self) QgsTextFormat[source]

Returns the text format used to render the text.

See also

setFormat()

Return type:

QgsTextFormat

margins(self) QgsMargins

Returns the margins between the outside of the item’s frame and the interior text.

Units are retrieved via marginsUnit()

See also

setMargins()

See also

marginsUnit()

Return type:

QgsMargins

marginsUnit(self) Qgis.RenderUnit[source]

Returns the units for the margins between the item’s frame and the interior text.

See also

setMarginsUnit()

See also

margins()

Return type:

Qgis.RenderUnit

setAlignment(self, alignment: Qt.Alignment | Qt.AlignmentFlag)[source]

Sets the text’s alignment relative to the bounds() rectangle.

See also

alignment()

Parameters:

alignment (Union[Qt.Alignment, Qt.AlignmentFlag])

setFormat(self, format: QgsTextFormat)[source]

Sets the text format used to render the text.

See also

format()

Parameters:

format (QgsTextFormat)

setMargins(self, margins: QgsMargins)[source]

Sets the margins between the outside of the item’s frame and the interior text.

Units are set via setMarginsUnit()

See also

margins()

See also

setMarginsUnit()

Parameters:

margins (QgsMargins)

setMarginsUnit(self, unit: Qgis.RenderUnit)[source]

Sets the unit for the margins between the item’s frame and the interior text.

See also

margins()

See also

marginsUnit()

Parameters:

unit (Qgis.RenderUnit)

setText(self, text: str | None)[source]

Sets the text rendered by the item.

See also

text()

Parameters:

text (Optional[str])

text(self) str[source]

Returns the text rendered by the item.

See also

setText()

Return type:

str