PDA

View Full Version : How show progress of slow a operation?



shud
3rd December 2009, 19:31
I need to show the progress of a slow operation , but I doesn´t have a loop to set the values for a qprogressdialog.
I have only a call to a method compute(); but I don´t have get access to his internal code.

schnitzel
3rd December 2009, 19:51
I believe threading is your only option then:
http://doc.qt.nokia.com/4.6/threads.html

squidge
3rd December 2009, 19:52
throw compute() into a seperate thread, and then do some animation until the thread returns.

shud
3rd December 2009, 19:58
but , the thread can pass or set the value of the q?progressdialog?

squidge
3rd December 2009, 20:04
No, you set the volume of the progress dialog in your main gui loop using a timer.

shud
3rd December 2009, 20:08
Ok, but my problem is that the operation sometimes is fast (depending of his entries) and other times is very slow , so predefined a time is very difficult.

schnitzel
3rd December 2009, 20:43
QProgressDialog supports marquee style which just moves the progess back and forth to show that something is happening but it is unknown how long it will take.

squidge
3rd December 2009, 20:52
The thread will send you a signal when it is completed, so you can remove the progress bar. Therefore it doesn't matter if the task takes long time or short time.

schnitzel
3rd December 2009, 21:09
The thread will send you a signal when it is completed, so you can remove the progress bar. Therefore it doesn't matter if the task takes long time or short time.

If I understand shud correctly, then the 'volume' is unknown, so in that case it is better to make the progressbar go back and forth - imho.

squidge
3rd December 2009, 23:10
If I understand shud correctly, then the 'volume' is unknown, so in that case it is better to make the progressbar go back and forth - imho.Yes, and I completely agree with you, but you still need to remove that progress bar when the task is finished, hence why I mentioned using the signal that the thread object will send when the thread completes execution.