I have a for-loop which is setting the value of the progress bar on every iteration.
The for-loop executes the setProgress-method described here:
void setProgress(int progStep){
progressBar->setValue(progStep);
progStep++;
QTextStream(stdout) << progStep << " " << progSum << endl;
}
I can print out that last line, so the method is executed but the GUI of the progress bar is not updated every time.
When I have a maximum value of 25 (and min 0), the method prints every number from 0-25. My goal is to have the progress bar to then show 25 different percentage values during this execution.
Structure:
for(.....) {
.....
.....
setProgress(progStep);
}
What actually happens is that it updates the progress bar with percentage values about 2-3 times. The for-loop takes about 30 seconds so it should definitely be able to make 25 percentage updates.
How can I solve this?
You have to call
QApplication::processEvents()after callingsetProgress(progStep), to let the GUI thread update the progress bar.