Class: QgsAnnotationManager

class qgis.core.QgsAnnotationManager

Bases: PyQt5.QtCore.QObject

Manages storage of a set of QgsAnnotation annotation objects.

QgsAnnotationManager handles the storage, serializing and deserializing of QgsAnnotations. Usually this class is not constructed directly, but rather accessed through a QgsProject via QgsProject.annotationManager().

QgsAnnotationManager retains ownership of all the annotations contained in the manager.

New in version 3.0.

QgsAnnotationManager(project: QgsProject = None) Constructor for QgsAnnotationManager. The project will become the parent object for this manager.

Methods

accept

Accepts the specified style entity visitor, causing it to visit all style entities associated within the contained annotations.

addAnnotation

Adds an annotation to the manager.

annotations

Returns a list of all annotations contained in the manager.

childEvent

clear

Removes and deletes all annotations from the manager.

cloneAnnotations

Returns a list containing clones of all annotations contained in the manager.

connectNotify

customEvent

disconnectNotify

isSignalConnected

readXml

Reads the manager's state from a DOM element, restoring all annotations present in the XML document.

receivers

removeAnnotation

Removes an annotation from the manager.

sender

senderSignalIndex

timerEvent

writeXml

Returns a DOM element representing the state of the manager.

Signals

annotationAboutToBeRemoved

Emitted when an annotation is about to be removed from the manager [signal]

annotationAdded

Emitted when a annotation has been added to the manager [signal]

annotationRemoved

Emitted when an annotation was removed from the manager [signal]

accept(self, visitor: QgsStyleEntityVisitorInterface) bool

Accepts the specified style entity visitor, causing it to visit all style entities associated within the contained annotations.

Returns True if the visitor should continue visiting other objects, or False if visiting should be canceled.

New in version 3.10.

Parameters

visitor (QgsStyleEntityVisitorInterface) –

Return type

bool

addAnnotation(self, annotation: QgsAnnotation) bool

Adds an annotation to the manager. Ownership of the annotation is transferred to the manager. Returns True if the addition was successful, or False if the annotation could not be added.

Parameters

annotation (QgsAnnotation) –

Return type

bool

annotationAboutToBeRemoved

Emitted when an annotation is about to be removed from the manager [signal]

Parameters

annotation (QgsAnnotation) –

annotationAdded

Emitted when a annotation has been added to the manager [signal]

Parameters

annotation (QgsAnnotation) –

annotationRemoved

Emitted when an annotation was removed from the manager [signal]

annotations(self) List[QgsAnnotation]

Returns a list of all annotations contained in the manager.

Return type

List[QgsAnnotation]

childEvent(self, QChildEvent)
clear(self)

Removes and deletes all annotations from the manager.

cloneAnnotations(self) List[QgsAnnotation]

Returns a list containing clones of all annotations contained in the manager. The caller takes responsibility for deleting all returned annotations.

See also

annotations()

Return type

List[QgsAnnotation]

connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
disconnectNotify(self, QMetaMethod)
isSignalConnected(self, QMetaMethod) bool
readXml(self, element: QDomElement, context: QgsReadWriteContext) bool

Reads the manager’s state from a DOM element, restoring all annotations present in the XML document.

See also

writeXml()

Parameters
Return type

bool

receivers(self, PYQT_SIGNAL) int
removeAnnotation(self, annotation: QgsAnnotation) bool

Removes an annotation from the manager. The annotation is deleted. Returns True if the removal was successful, or False if the removal failed (eg as a result of removing an annotation which is not contained in the manager).

See also

addAnnotation()

See also

clear()

Parameters

annotation (QgsAnnotation) –

Return type

bool

sender(self) QObject
senderSignalIndex(self) int
timerEvent(self, QTimerEvent)
writeXml(self, doc: QDomDocument, context: QgsReadWriteContext) QDomElement

Returns a DOM element representing the state of the manager.

See also

readXml()

Parameters
Return type

QDomElement