QgsFeedback class
Base class for feedback objects to be used for cancelation of something running in a worker thread.
Contents
The class may be used as is or it may be subclassed for extended functionality for a particular operation (e.g. report progress or pass some data for preview).
When cancel() is called, the internal code has two options to check for cancelation state:
- if the worker thread uses an event loop (e.g. for network communication), the code can make a queued connection to canceled() signal and handle the cancelation in its slot.
- if the worker thread does not use an event loop, it can poll isCanceled() method regularly to see if the operation should be canceled.
The class is meant to be created and destroyed in the main thread.
For map rendering, the object may be created in constructor of a QgsMapLayerRenderer subclass and available with QgsMapLayerRenderer::
Derived classes
- class QgsProcessingFeedback
- Base class for providing feedback from a processing algorithm.
- class QgsRasterBlockFeedback
- Feedback object tailored for raster block reading.
- class QgsVectorLayerRendererInterruptionChecker
- Interruption checker used by QgsVectorLayerRenderer::
render()
Constructors, destructors, conversion operators
- QgsFeedback(QObject* parent = nullptr)
- Construct a feedback object.
Public functions
- auto isCanceled() const -> bool
- Tells whether the operation has been canceled already.
- auto progress() const -> double
- Returns the current progress reported by the feedback object.
- void setProgress(double progress)
- Sets the current progress for the feedback object.
Signals
- void canceled()
- Internal routines can connect to this signal if they use event loop.
- void progressChanged(double progress)
- Emitted when the feedback object reports a progress change.
Public slots
- void cancel()
- Tells the internal routines that the current operation should be canceled. This should be run by the main thread.
Function documentation
double QgsFeedback:: progress() const
Returns the current progress reported by the feedback object.
Depending on how the feedback object is used progress reporting may not be supported. The returned value is in percentage and ranges from 0-100.
void QgsFeedback:: setProgress(double progress)
Sets the current progress for the feedback object.
The progress argument is in percentage and valid values range from 0-100.
void QgsFeedback:: progressChanged(double progress) signal
Emitted when the feedback object reports a progress change.
Depending on how the feedback object is used progress reporting may not be supported. The progress argument is in percentage and ranges from 0-100.