I have a series of tasks that need to happen on a set of images. There are 3 steps which I want to run one after each other, but the middle one needs to be run serially because it relies on the results of all the previous iterations. What I want is to relay the progress of these three tasks back to the UI using a QFutureWatcher
. I already have other tasks that do this and hook into progress bars etc, so kinda what to use the same process if I can. The way I'm thinking of implementing is to have an internal QFuture
and QFutureWatcher
that runs each task, and one external QFutureWatcher
that monitors this an relays info to the UI. Maybe something like this (pseudo code):
runProcessingTask() {
connect(externalFutureWatcher, UI elements)
internalFuture = start first task
internalFutureWatcher.setFuture(internalFuture)
connect(internalFuture.finished(), taskfinished())
connect(internalFuture.progressValue(), updateProgress())
taskNumber = 1
}
taskFinished() {
switch(taskNumber):
case 1:
internalFuture = start second task
internalFutureWatcher.setFuture(internalFuture)
taskNumber = 2
case 2:
internalFuture = start third task
internalFutureWatcher.setFuture(internalFuture)
taskNumber = 3
case 3:
externalFutureWatcher.setFinished()
}
updateProgress() {
switch(taskNumber):
case 1:
extrenalFutureWatcher.setProgress(internalFutureWatcher.progress() / 3)
case 2:
extrenalFutureWatcher.setProgress(33.3% + (internalFutureWatcher.progress() / 3))
case 3:
extrenalFutureWatcher.setProgress(66.6% + (internalFutureWatcher.progress() / 3))
}
Would this sort of thing be possible? Do I just need to override some methods in QFutureWatcher
and use them as my externalFutureWatcher? Or is it not possible in this way/ is there a much better way of doing this?