[Qt-interest] Controlling when timers run

Sean Harmer sean.harmer at maps-technology.com
Fri Jan 15 00:41:14 CET 2010


Hi,

Glenn Hughes wrote:
> Hi Sean, yes, that helps, 

OK good at least that solves at least some of the problems.

> but I'd like a way of doing this so that the
> programmer does not need to remember to do the
> TimerManager::instance()->stopTimers(); /
> TimerManager::instance()->startTimers(); around each call to exec.
> The
> more stuff like that the programmer needs to do the less likely they
> will remember to do them, and the more likely bugs will sneak in.

Well, you could derive your own base class for dialogs that does it for 
you when you call exec() to make this less cumbersome for the 
programmers. All they have to remember to do then is to derive their 
dialogs from your custom class rather than directly from QDialog.

If this is still too onerous an undertaking then you could look at 
moving your timer driven processing into a separate worker thread as 
then you will only have a single event loop in that thread. However, you 
would then need some kind of synchronisation with the main GUI thread as 
to when processing can be done.

> Thanks!

You're welcome.

All the best,

Sean



More information about the Qt-interest-old mailing list