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

Methods

addAnnotations

Adds annotations to be rendered on the map.

addDecorations

Adds decorations to be rendered on the map.

setExportMetadata

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

setSaveWorldFile

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

Signals

errorOccurred

Emitted when map rendering failed.

renderingComplete

Emitted when the map rendering is successfully completed.

Attributes

ImageAllocationFail

ImageSaveFail

ImageUnsupportedFormat

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(error: int)[source]

Emitted when map rendering failed.

Parameters:

error (int)

signal renderingComplete[source]

Emitted when the map rendering is successfully completed.

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)