Class: QgsAnnotationLineTextItem

An annotation item which renders text along a line geometry.

Added in version 3.32.

Class Hierarchy

Inheritance diagram of qgis.core.QgsAnnotationLineTextItem

Base classes

QgsAnnotationItem

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

Methods

format

Returns the text format used to render the text.

geometry

Returns the geometry of the item.

offsetFromLine

Returns the offset distance from the line geometry() to the text's baseline.

offsetFromLineMapUnitScale

Returns the map unit scale for the offset from line geometry() distance.

offsetFromLineUnit

Returns the units for the offset from line geometry() distance.

setFormat

Sets the text format used to render the text.

setGeometry

Sets the geometry of the item.

setOffsetFromLine

Sets the offset distance from the line geometry() to the text's baseline.

setOffsetFromLineMapUnitScale

Sets the map unit scale for the offset from line geometry() distance.

setOffsetFromLineUnit

Sets the unit for the offset from line geometry() distance.

setText

Sets the text rendered by the item.

text

Returns the text rendered by the item.

Static Methods

create

Creates a new linestring annotation item.

class qgis.core.QgsAnnotationLineTextItem[source]

Bases: QgsAnnotationItem

__init__(text: str | None, curve: QgsCurve | None)

Constructor for QgsAnnotationLineTextItem, with the specified curve and text.

Parameters:
  • text (Optional[str])

  • curve (Optional[QgsCurve])

static create() QgsAnnotationLineTextItem | None[source]

Creates a new linestring annotation item.

Return type:

Optional[QgsAnnotationLineTextItem]

format(self) QgsTextFormat[source]

Returns the text format used to render the text.

See also

setFormat()

Return type:

QgsTextFormat

geometry(self) QgsCurve | None[source]

Returns the geometry of the item.

The coordinate reference system for the line will be the parent layer’s QgsAnnotationLayer.crs().

See also

setGeometry()

Return type:

Optional[QgsCurve]

offsetFromLine(self) float[source]

Returns the offset distance from the line geometry() to the text’s baseline. Units are specified through offsetFromLineUnit().

Return type:

float

offsetFromLineMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the offset from line geometry() distance.

See also

offsetFromLine()

Return type:

QgsMapUnitScale

offsetFromLineUnit(self) Qgis.RenderUnit[source]

Returns the units for the offset from line geometry() distance.

See also

offsetFromLine()

Return type:

Qgis.RenderUnit

setFormat(self, format: QgsTextFormat)[source]

Sets the text format used to render the text.

See also

format()

Parameters:

format (QgsTextFormat)

setGeometry(self, geometry: QgsCurve | None)[source]

Sets the geometry of the item. Ownership of geometry is transferred.

The coordinate reference system for the line will be the parent layer’s QgsAnnotationLayer.crs().

See also

geometry()

Parameters:

geometry (Optional[QgsCurve])

setOffsetFromLine(self, distance: float)[source]

Sets the offset distance from the line geometry() to the text’s baseline. Units are specified through setOffsetFromLineUnit().

See also

offsetFromLine()

Parameters:

distance (float)

setOffsetFromLineMapUnitScale(self, scale: QgsMapUnitScale)[source]

Sets the map unit scale for the offset from line geometry() distance.

Parameters:

scale (QgsMapUnitScale)

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

Sets the unit for the offset from line geometry() distance.

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