[Qt-interest] processEvents() and reset.

Andreas Pakulat apaku at gmx.de
Fri Oct 29 19:16:33 CEST 2010


On 29.10.10 16:27:32, phil prentice wrote:
>   I have a simple dialog. When you click a button on the dialog a slot is 
> called that loops around some code performing an action.  I have another slot 
> that gets called when another button(reset) is pressed on the same dialog.  I 
> use processEvents() within the loop to catch the reset button being pressed.  
> This works absolutely fine if I leave the mouse inside of the dialog.  I can 
> start the loop and reset the loop with no problems.  Its lovely and simple!!!
> 
>   Unfortunately I have a problem; if I move the mouse outside of the dialog 
> and back in...the reset button no longer responds quite so well. I presume 
> that its got something to do with the focus changing???  But reset is 
> certainly not quick then...in fact sometimes I cant get it to work at all.
> 
>   Is there a quick fix for this?

Without seeing some code my suggestion is to check for any code that can
be executed when events are being fired. With your processEvents calling
you're processing all events in your application. So any code that
handles events can be executed while you're in your loop. So there might
be code in your app that gets executed which you don't expect to be on a
first look.

Its not quite clear why you're calling processEvents, options to avoid
it are splitting up the work into smaller/shorter pieces and executing
them in steps with a timer for example. Or move the logic into a
separate thread so that the normal event loop can continue.

Andreas

-- 
You will be traveling and coming into a fortune.



More information about the Qt-interest-old mailing list