Class: QgsVectorLayerExporterTask

QgsTask task which performs a QgsVectorLayerExporter layer export operation as a background task.

This can be used to export a vector layer out to a provider without blocking the QGIS interface.

Class Hierarchy

Inheritance diagram of qgis.core.QgsVectorLayerExporterTask

Base classes

QgsTask

Abstract base class for long running background tasks.

QObject

Static Methods

withLayerOwnership

Creates a new QgsVectorLayerExporterTask which has ownership over a source layer.

Signals

errorOccurred

Emitted when an error occurs which prevented the layer being exported (or if the task is canceled).

exportComplete

Emitted when exporting the layer is successfully completed.

class qgis.core.QgsVectorLayerExporterTask[source]

Bases: QgsTask

__init__(layer: QgsVectorLayer | None, uri: str | None, providerKey: str | None, destinationCrs: QgsCoordinateReferenceSystem, options: Dict[str | None, Any] = {}, ownsLayer: bool = False)

Constructor for QgsVectorLayerExporterTask. Takes a source layer, destination uri and providerKey, and various export related parameters such as destination CRS and export options. ownsLayer has to be set to True if the task should take ownership of the layer and delete it after export.

Parameters:
__init__(layer: QgsVectorLayer | None, uri: str | None, providerKey: str | None, exportOptions: QgsVectorLayerExporter.ExportOptions, providerOptions: Dict[str | None, Any] = {}, ownsLayer: bool = False)

Constructor for QgsVectorLayerExporterTask. Takes a source layer, destination uri and providerKey, and various export related parameters via the exportOptions argument.

ownsLayer has to be set to True if the task should take ownership of the layer and delete it after export.

Added in version 3.44.

Parameters:
signal errorOccurred(error: Qgis.VectorExportResult, errorMessage: str)[source]

Emitted when an error occurs which prevented the layer being exported (or if the task is canceled). The export error and errorMessage will be reported.

Parameters:
signal exportComplete[source]

Emitted when exporting the layer is successfully completed.

static withLayerOwnership(layer: QgsVectorLayer | None, uri: str | None, providerKey: str | None, destinationCrs: QgsCoordinateReferenceSystem, options: Dict[str | None, Any] = {}) QgsVectorLayerExporterTask | None[source]

Creates a new QgsVectorLayerExporterTask which has ownership over a source layer. When the export task has completed (successfully or otherwise) layer will be deleted. The destination uri and providerKey, and various export related parameters such as destination CRS and export options must be specified.

Parameters:
Return type:

Optional[QgsVectorLayerExporterTask]