Class: QgsMapRendererTask

QgsTask task which draws a map to an image file or a painter as a background task.

This can be used to draw maps without blocking the QGIS interface.

Class Hierarchy

Inheritance diagram of qgis.core.QgsMapRendererTask

Base classes

QgsTask

Abstract base class for long running background tasks.

QObject

class qgis.core.QgsMapRendererTask[source]

Bases: QgsTask

__init__(ms: QgsMapSettings, fileName: str | None, fileFormat: str | None = '', forceRaster: bool = False, flags: QgsTask.Flags | QgsTask.Flag = QgsTask.CanCancel)

Constructor for QgsMapRendererTask to render a map to an image file.

Since QGIS 3.26 the optional flags argument can be used to control the task flags.

Parameters:
__init__(ms: QgsMapSettings, p: QPainter | None)

Constructor for QgsMapRendererTask to render a map to a QPainter object.

Parameters:
class ErrorType

Bases: int

ImageAllocationFail = 1
ImageSaveFail = 2
ImageUnsupportedFormat = 3
addAnnotations(self, annotations: Iterable[QgsAnnotation])[source]

Adds annotations to be rendered on the map.

Parameters:

annotations (Iterable[QgsAnnotation])

addDecorations(self, decorations: Iterable[QgsMapDecoration])[source]

Adds decorations to be rendered on the map.

Parameters:

decorations (Iterable[QgsMapDecoration])

signal errorOccurred[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

signal renderingComplete[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

setExportMetadata(self, exportMetadata: bool)[source]

Sets whether metadata such as title and subject will be exported whenever possible.

Parameters:

exportMetadata (bool)

setSaveWorldFile(self, save: bool)[source]

Sets whether the image file will be georeferenced (embedded or via a world file).

Parameters:

save (bool)