Hi,
I have a program of important calculations, with GUI including a label to display status of calculations, and a progress bar to update the progression. How ever, the reaction of content of the label and progress bar is slow. My code looks like (in simplified structure):
void testa::main_calc () {
ui.label->setText("Preparing..."); // doesn't display
// important calculations here
ui.label->setText("Running..."); // display
for(int i=0; i<100; i++) {
// important calculations here
ui.progressBar->setValue(i); // only displays to 40-50%
}
// important calculations
ui.label->setText("Processing..."); // doesn't display
// important calculations
ui.progressBar->setValue(100); // display
ui.label->setText("Finished."); // display
}
It seems when the calculations are intense, the contents of elements of GUI are not reactive. However, when there is a ui.progressBar->setValue()
before ui.label->setText()
, the label can display normally.
Could anyone please tell me how the fix it, and make it reactive? (before this code, I have made a simple one (no important calculations) with same structure, it worked perfectly.) Thanks in advance!
↧