Class: QgsFeedback

class qgis.core.QgsFeedback

Bases: PyQt5.QtCore.QObject

Base class for feedback objects to be used for cancellation of something running in a worker thread.

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 cancellation 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 cancellation 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.feedback() method. When a map rendering job gets canceled, the cancel() method is called on the feedback object of all layers.

QgsFeedback(parent: QObject = None) Construct a feedback object

Methods

cancel

Tells the internal routines that the current operation should be canceled.

childEvent

connectNotify

customEvent

disconnectNotify

isCanceled

Tells whether the operation has been canceled already

isSignalConnected

processedCount

Returns the current processed objects count reported by the feedback object.

progress

Returns the current progress reported by the feedback object.

receivers

sender

senderSignalIndex

setProcessedCount

Sets the current processed objects count for the feedback object.

setProgress

Sets the current progress for the feedback object.

timerEvent

Signals

canceled

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

progressChanged

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

cancel(self)

Tells the internal routines that the current operation should be canceled. This should be run by the main thread

canceled

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

childEvent(self, QChildEvent)
connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
disconnectNotify(self, QMetaMethod)
isCanceled(self) bool

Tells whether the operation has been canceled already

Return type:

bool

isSignalConnected(self, QMetaMethod) bool
processedCount(self) int

Returns the current processed objects count reported by the feedback object. Depending on how the feedback object is used processed count reporting may not be supported. The returned value is an unsigned long integer and starts from 0.

See also

processedCountChanged()

New in version 3.24.

Return type:

int

progress(self) float

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.

See also

setProgress()

Return type:

float

progressChanged

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

receivers(self, PYQT_SIGNAL) int
sender(self) QObject
senderSignalIndex(self) int
setProcessedCount(self, processedCount: int)

Sets the current processed objects count for the feedback object. The processedCount argument is an unsigned long integer and starts from 0.

See also

processedCount()

See also

processedCountChanged()

New in version 3.24.

Parameters:

processedCount (int) –

setProgress(self, progress: float)

Sets the current progress for the feedback object. The progress argument is in percentage and valid values range from 0-100.

See also

progress()

Parameters:

progress (float) –

timerEvent(self, QTimerEvent)