QgsProcessingAlgRunnerTask class
QgsTask task which runs a QgsProcessingAlgorithm in a background task.
Contents
Base classes
- class QgsTask
- Abstract base class for long running background tasks.
Constructors, destructors, conversion operators
- QgsProcessingAlgRunnerTask(const QgsProcessingAlgorithm* algorithm, const QVariantMap& parameters, QgsProcessingContext& context, QgsProcessingFeedback* feedback = nullptr)
- Constructor for QgsProcessingAlgRunnerTask.
Public functions
- void cancel() override
- Notifies the task that it should terminate.
Signals
- void executed(bool successful, const QVariantMap& results)
- Emitted when the algorithm has finished execution.
Protected functions
- void finished(bool result) override
- 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).
- auto run() -> bool override
- Performs the task's operation.
Function documentation
QgsProcessingAlgRunnerTask:: QgsProcessingAlgRunnerTask(const QgsProcessingAlgorithm* algorithm,
const QVariantMap& parameters,
QgsProcessingContext& context,
QgsProcessingFeedback* feedback = nullptr)
Constructor for QgsProcessingAlgRunnerTask.
Takes an algorithm, algorithm parameters and processing context.
void QgsProcessingAlgRunnerTask:: cancel() override
Notifies the task that it should terminate.
Calling this is not guaranteed to immediately end the task, rather it sets the isCanceled() flag which task subclasses can check and terminate their operations at an appropriate time. Any subtasks owned by this task will also be canceled. Derived classes must ensure that the base class implementation is called from any overridden version.
void QgsProcessingAlgRunnerTask:: executed(bool successful,
const QVariantMap& results) signal
Emitted when the algorithm has finished execution.
If the algorithm completed execution without errors then successful will be true. The results argument contains the results reported by the algorithm.
void QgsProcessingAlgRunnerTask:: finished(bool result) override protected
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.
bool QgsProcessingAlgRunnerTask:: run() override protected
Performs the task's operation.
This method will be called when the task commences (ie via calling start() ), and subclasses should implement the operation they wish to perform in the background within this method.
A task must return a boolean value to indicate whether the task was completed successfully or terminated before completion.