QgsTextAnnotation class

An annotation item that displays formatted text from a QTextDocument document.

Base classes

class QgsAnnotation
Abstract base class for annotation items which are drawn over a map.

Public static functions

static auto create() -> QgsTextAnnotation*
Returns a new QgsTextAnnotation object.

Constructors, destructors, conversion operators

QgsTextAnnotation(QObject* parent = nullptr)
Constructor for QgsTextAnnotation.

Public functions

auto clone() const -> QgsTextAnnotation* override
Clones the annotation, returning a new copy of the annotation reflecting the annotation's current state.
auto document() const -> const QTextDocument*
Returns the text document which will be rendered within the annotation.
void readXml(const QDomElement& itemElem, const QgsReadWriteContext& context) override
Restores the annotation's state from a DOM element.
void setDocument(const QTextDocument* doc)
Sets the text document which will be rendered within the annotation.
void writeXml(QDomElement& elem, QDomDocument& doc, const QgsReadWriteContext& context) const override
Writes the annotation state to a DOM element.

Protected functions

void renderAnnotation(QgsRenderContext& context, QSizeF size) const override
Renders the annotation's contents to a target /a context at the specified /a size.

Function documentation

const QTextDocument* QgsTextAnnotation::document() const

Returns the text document which will be rendered within the annotation.

void QgsTextAnnotation::readXml(const QDomElement& itemElem, const QgsReadWriteContext& context) override

Restores the annotation's state from a DOM element.

Derived classes should call _readXml() within their implementation of this method.

void QgsTextAnnotation::setDocument(const QTextDocument* doc)

Sets the text document which will be rendered within the annotation.

Ownership is not transferred.

void QgsTextAnnotation::writeXml(QDomElement& elem, QDomDocument& doc, const QgsReadWriteContext& context) const override

Writes the annotation state to a DOM element.

Derived classes should call _writeXml() within their implementation of this method.

void QgsTextAnnotation::renderAnnotation(QgsRenderContext& context, QSizeF size) const override protected

Renders the annotation's contents to a target /a context at the specified /a size.

Derived classes should implement their custom annotation drawing logic here.