Class: QgsAnnotationLineTextItem

class qgis.core.QgsAnnotationLineTextItem

Bases: QgsAnnotationItem

An annotation item which renders text along a line geometry.

New in version 3.32.

QgsAnnotationLineTextItem(text: str, curve: QgsCurve) Constructor for QgsAnnotationLineTextItem, with the specified curve and text.

Methods

applyEdit

param operation:

boundingBox

rtype:

QgsRectangle

clone

rtype:

QgsAnnotationLineTextItem

copyCommonProperties

Copies common properties from the base class from an other item.

create

Creates a new linestring annotation item.

flags

rtype:

Qgis.AnnotationItemFlags

format

Returns the text format used to render the text.

geometry

Returns the geometry of the item.

nodes

rtype:

List[QgsAnnotationItemNode]

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.

readCommonProperties

Reads common properties from the base class from the given DOM element.

readXml

param element:

render

param context:

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.

transientEditResults

param operation:

type

rtype:

str

writeCommonProperties

Writes common properties from the base class into an XML element.

writeXml

param element:

applyEdit(self, operation: QgsAbstractAnnotationItemEditOperation) Qgis.AnnotationItemEditOperationResult
Parameters:

operation (QgsAbstractAnnotationItemEditOperation) –

Return type:

Qgis.AnnotationItemEditOperationResult

boundingBox(self) QgsRectangle
boundingBox(self, context: QgsRenderContext) QgsRectangle
Return type:

QgsRectangle

clone(self) QgsAnnotationLineTextItem
Return type:

QgsAnnotationLineTextItem

copyCommonProperties(self, other: QgsAnnotationItem)

Copies common properties from the base class from an other item.

New in version 3.22.

create() QgsAnnotationLineTextItem

Creates a new linestring annotation item.

Return type:

QgsAnnotationLineTextItem

flags(self) Qgis.AnnotationItemFlags
Return type:

Qgis.AnnotationItemFlags

format(self) QgsTextFormat

Returns the text format used to render the text.

See also

setFormat()

Return type:

QgsTextFormat

geometry(self) QgsCurve

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:

QgsCurve

nodes(self) List[QgsAnnotationItemNode]
Return type:

List[QgsAnnotationItemNode]

offsetFromLine(self) float

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

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

See also

offsetFromLine()

Return type:

Qgis.RenderUnit

readCommonProperties(self, element: QDomElement, context: QgsReadWriteContext) bool

Reads common properties from the base class from the given DOM element.

See also

readXml()

New in version 3.22.

readXml(self, element: QDomElement, context: QgsReadWriteContext) bool
Parameters:
Return type:

bool

render(self, context: QgsRenderContext, feedback: QgsFeedback)
Parameters:
setFormat(self, format: QgsTextFormat)

Sets the text format used to render the text.

See also

format()

Parameters:

format (QgsTextFormat) –

setGeometry(self, geometry: QgsCurve)

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 (QgsCurve) –

setOffsetFromLine(self, distance: float)

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)

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

Parameters:

scale (QgsMapUnitScale) –

setOffsetFromLineUnit(self, unit: Qgis.RenderUnit)

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

Parameters:

unit (Qgis.RenderUnit) –

setText(self, text: str)

Sets the text rendered by the item.

See also

text()

Parameters:

text (str) –

text(self) str

Returns the text rendered by the item.

See also

setText()

Return type:

str

transientEditResults(self, operation: QgsAbstractAnnotationItemEditOperation) QgsAnnotationItemEditOperationTransientResults
Parameters:

operation (QgsAbstractAnnotationItemEditOperation) –

Return type:

QgsAnnotationItemEditOperationTransientResults

type(self) str
Return type:

str

writeCommonProperties(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) bool

Writes common properties from the base class into an XML element.

See also

writeXml()

New in version 3.22.

writeXml(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) bool
Parameters:
Return type:

bool