Class: QgsVirtualLayerTask

class qgis.core.QgsVirtualLayerTask

Bases: QgsTask

Initializes a virtual layer with postpone mode activated and reloads the data in a separated thread.

New in version 3.2.

QgsVirtualLayerTask(definition: QgsVirtualLayerDefinition) Constructor.

Parameters

definition

The definition to use for initializing the virtual layer

Methods

cancel

Cancels the pending query and the parent task.

childEvent

connectNotify

customEvent

definition

Returns the virtual layer definition.

disconnectNotify

exceptionText

Returns the exception text or an empty string if no exceptions were raised

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

layer

Returns the underlying virtual layer.

receivers

run

Reloads the data.

sender

senderSignalIndex

setExceptionText

Sets the exceptionText

setProgress

Sets the task’s current progress.

takeLayer

Returns the underlying virtual layer and ownership.

timerEvent

cancel(self)

Cancels the pending query and the parent task.

childEvent(self, QChildEvent)
connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
definition(self) QgsVirtualLayerDefinition

Returns the virtual layer definition.

Return type

QgsVirtualLayerDefinition

disconnectNotify(self, QMetaMethod)
exceptionText(self) str

Returns the exception text or an empty string if no exceptions were raised

New in version 3.4.

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
layer(self) QgsVectorLayer

Returns the underlying virtual layer.

Return type

QgsVectorLayer

receivers(self, PYQT_SIGNAL) int
run(self) bool

Reloads the data.

Return type

bool

Returns

True if the virtual layer is valid, False otherwise.

sender(self) QObject
senderSignalIndex(self) int
setExceptionText(self, exceptionText: str)

Sets the exceptionText

New in version 3.4.

Parameters

exceptionText (str) –

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

takeLayer(self) QgsVectorLayer

Returns the underlying virtual layer and ownership.

Return type

QgsVectorLayer

timerEvent(self, QTimerEvent)