[clug] long run function in trolltech qt widget

Brad Hards bradh at frogmouth.net
Wed Dec 3 05:59:20 GMT 2008

On Wednesday 03 December 2008 04:02:13 pm jm wrote:
> I have a function which I didn't write, lets call this
> long_run(), which takes a few seconds to run. Luckily it takes a call
> back function, label this callback(), which it calls every now and then
> so you know things are progressing nicely. What I wish to do is display
> a wizard (using QWizard) so that the user can enter the required data
> and be stepped through the process then in one of the wizards pages run
> long_run() and display a QProgressBar to indicate that things are going
> on in the background. I've worked out how to pass C++ classes though C
> call and to get them execute (or at least not to crash). The problem is
> that I haven't worked out how to make the call to long_run() so that it
> starts when the relevent wizard page is displayed. I've tried
> implementing show() but that waits for the call to finish before
> displaying the page.

The normal approach would be to connect the accepted() signal to a custom slot 
that executes long_run().

However to show any GUI stuff changing, you need to return to the event loop. 
How is long_run() returning control to the event loop? Are you dividing up 
the run into multiple steps, or are using some kind of threading approach?


More information about the linux mailing list