Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Updating 'Current Elapsed Time' in the GUI
RBrNx277 last edited by
Hi there, I currently have a program which has two main sections, the mainWindow class which is the GUI portion of my program, and a SokoGenerator class which is running on a QThread so that the GUI can update while the Generator is running.
Id like to start a timer once a button is clicked, and then constantly update the GUI with the current elapsed time of the program, and then stop updating the timer once the Generator has finished it's execution. I tried to use the QTime Class but I was not very successful as I couldn't calculate the time difference using the following code:
QTime currentTime = QTime::currentTime(); QTime diffTime = currentTime - startTime; QString timeString = diffTime.toString("hh : mm : ss"); ui->label_GenerationTime->setText("Current Generation Time: " + timeString);
What is the best way to update a GUI Label with the current elapsed time, and then stop updating once the Generator has finished running?
RavensAngel last edited by
Look at this thread.