Class: QgsAnnotationManager¶
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.
Class Hierarchy¶
Base classes¶
Methods
Accepts the specified style entity visitor, causing it to visit all style entities associated within the contained annotations. |
|
Adds an annotation to the manager. |
|
Returns a list of all annotations contained in the manager. |
|
Removes and deletes all annotations from the manager. |
|
Returns a list containing clones of all annotations contained in the manager. |
|
Reads the manager's state from a DOM element, restoring all annotations present in the XML document. |
|
Removes an annotation from the manager. |
|
Returns a DOM element representing the state of the manager. |
Signals
Emitted when an annotation is about to be removed from the manager |
|
Emitted when a annotation has been added to the manager |
|
Emitted when an annotation was removed from the manager |
- class qgis.core.QgsAnnotationManager[source]¶
Bases:
QObject- __init__(project: QgsProject | None = None)
Constructor for QgsAnnotationManager. The project will become the parent object for this manager.
- Parameters:
project (Optional[QgsProject] = None)
- accept(self, visitor: QgsStyleEntityVisitorInterface | None) bool[source]¶
Accepts the specified style entity
visitor, causing it to visit all style entities associated within the contained annotations.Returns
Trueif the visitor should continue visiting other objects, orFalseif visiting should be canceled.Added in version 3.10.
- Parameters:
visitor (Optional[QgsStyleEntityVisitorInterface])
- Return type:
bool
- addAnnotation(self, annotation: QgsAnnotation | None) bool[source]¶
Adds an annotation to the manager. Ownership of the annotation is transferred to the manager. Returns
Trueif the addition was successful, orFalseif the annotation could not be added.See also
See also
- Parameters:
annotation (Optional[QgsAnnotation])
- Return type:
bool
- signal annotationAboutToBeRemoved(annotation: QgsAnnotation)[source]¶
Emitted when an annotation is about to be removed from the manager
- Parameters:
annotation (QgsAnnotation)
- signal annotationAdded(annotation: QgsAnnotation)[source]¶
Emitted when a annotation has been added to the manager
- Parameters:
annotation (QgsAnnotation)
- annotations(self) List[QgsAnnotation]¶
Returns a list of all annotations contained in the manager.
See also
- Return type:
List[QgsAnnotation]
- 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
- Return type:
List[QgsAnnotation]
- readXml(self, element: QDomElement, context: QgsReadWriteContext) bool[source]¶
Reads the manager’s state from a DOM element, restoring all annotations present in the XML document.
See also
- Parameters:
element (QDomElement)
context (QgsReadWriteContext)
- Return type:
bool
- removeAnnotation(self, annotation: QgsAnnotation | None) bool[source]¶
Removes an annotation from the manager. The annotation is deleted. Returns
Trueif the removal was successful, orFalseif the removal failed (eg as a result of removing an annotation which is not contained in the manager).See also
See also
See also
See also
- Parameters:
annotation (Optional[QgsAnnotation])
- Return type:
bool
- writeXml(self, doc: QDomDocument, context: QgsReadWriteContext) QDomElement[source]¶
Returns a DOM element representing the state of the manager.
See also
- Parameters:
doc (QDomDocument)
context (QgsReadWriteContext)
- Return type:
QDomElement