Update QLabel text in a loop
Solved
General and Desktop
-
Hi,
I am trying to show the result of each step of my algorithm in a QLabel to verify the execution, but the QLabel doesn't change.
I think the problem is because each step take 5 second approximately but I don't understand the problem.Here is the part of my code :
for(int t(0) ; t < limit ; t++) { /* execution of the step t of the algorithm ( 5 second approximately ) */ resultLabel->setText("result"+ <result here>) }
I also tried to do it with a QMessageBox::information and it works, but I have to click Ok every time :
for(int t(0) ; t < limit ; t++) { /* execution of the step t of the algorithm ( 5 second approximately ) */ QMessageBox::information(this,"result",<result here>) }
Thanks
-
-
Thanks for your answer, unfortunately this part of my code is executed in a class that inherits from QMainWindow, I don't have access to the QApplication.
Edit:
It works using QCoreApplication::processEvents() instead.