Class: QgsProfileExporterTask

class qgis.core.QgsProfileExporterTask

Bases: QgsTask

Handles exports of elevation profiles in various formats in a background task.

New in version 3.32.

QgsProfileExporterTask(sources: Iterable[QgsAbstractProfileSource], request: QgsProfileRequest, type: Qgis.ProfileExportType, destination: str, transformContext: QgsCoordinateTransformContext) Constructor for QgsProfileExporterTask, saving results to the specified destination file.

If destination is an empty string then the profile results will be generated only and can be retrieved by calling takeLayers().

Enums

ExportResult

Bases: enum.IntEnum

Methods

cancel

childEvent

connectNotify

createdFiles

Returns a list of layer files created during the export.

customEvent

disconnectNotify

error

Returns a descriptive error message, if available.

finished

If the task is managed by a QgsTaskManager, this will be called after the task has finished (whether through successful completion or via early termination).

isCanceled

Will return True if task should terminate ASAP.

isSignalConnected

receivers

result

Returns the result of the export operation.

run

rtype:

bool

sender

senderSignalIndex

setProgress

Sets the task's current progress.

takeLayers

Returns a list of vector layer containing the exported profile results.

timerEvent

class ExportResult(value)

Bases: enum.IntEnum

Results of exporting the profile.

  • Success: Successful export

  • Empty: Results were empty

  • DeviceError: Could not open output file device

  • DxfExportFailed: Generic error when outputting to DXF

  • LayerExportFailed: Generic error when outputting to files

  • Canceled: Export was canceled

Canceled = 5
DeviceError = 2
DxfExportFailed = 3
Empty = 1
LayerExportFailed = 4
Success = 0
baseClass

alias of QgsProfileExporterTask

cancel(self)
childEvent(self, QChildEvent)
connectNotify(self, QMetaMethod)
createdFiles(self) List[str]

Returns a list of layer files created during the export.

Return type:

List[str]

customEvent(self, QEvent)
disconnectNotify(self, QMetaMethod)
error(self) str

Returns a descriptive error message, if available.

Return type:

str

finished(self, result: bool)

If the task is managed by a QgsTaskManager, this will be called after the task has finished (whether through successful completion or via early termination). The result argument reflects whether the task was successfully completed or not. This method is always called from the main thread, so it is safe to create widgets and perform other operations which require the main thread. However, the GUI will be blocked for the duration of this method so tasks should avoid performing any lengthy operations here.

isCanceled(self) bool

Will return True if task should terminate ASAP. If the task reports the CanCancel flag, then derived classes’ run() methods should periodically check this and terminate in a safe manner.

isSignalConnected(self, QMetaMethod) bool
receivers(self, PYQT_SIGNAL) int
result(self) QgsProfileExporterTask.ExportResult

Returns the result of the export operation.

See also

error()

Return type:

QgsProfileExporterTask.ExportResult

run(self) bool
Return type:

bool

sender(self) QObject
senderSignalIndex(self) int
setProgress(self, progress: float)

Sets the task’s current progress. The derived class should call this method whenever the task wants to update its progress. Calling will automatically emit the progressChanged signal.

Parameters:

progress – percent of progress, from 0.0 - 100.0

takeLayers(self) List[QgsVectorLayer]

Returns a list of vector layer containing the exported profile results.

While this method attempts to condense all results into a single layer, multiple layers may be returned when the geometry types of exported features differs.

Ownership of the returned layers is transferred to the caller.

Return type:

List[QgsVectorLayer]

timerEvent(self, QTimerEvent)