How to update QProgressBar on QWizard multithreaded?

471 Views Asked by At

I have a QWizard subclass that for some pages, it will take a long time calling a method, so I want to put in a QProgressBar. My first thought is I created a QTimer and setup a method to gets called to updateProgressBar, but it seems that this runs in the same thread as the Wizard, so only gets updated when the QWizard is not busy. How can I get this to run in another thread?

2

There are 2 best solutions below

0
On

Thanks, I ended creating a QThread object in my QWizard class and calling moveToThread to move objects to thread. Such as http://www.developer.nokia.com/Community/Wiki/How_to_move_a_QObject_to_a_thread

0
On

Move your long running task into a worker thread that is a subclass of QThread. Have the worker thread emit a signal to indicate its progress (percent complete, if you can know that), and connect that signal to your progress bar's setValue(int) slot.