[Qt-interest] Controlling when timers run

Sean Harmer sean.harmer at maps-technology.com
Fri Jan 15 01:39:31 CET 2010


D'Oh. I knew I was missing something obvious.

The only thing you have to be careful of is the other checks that 
QApplication does in exec() such as making sure it is being run from the 
  main GUI thread and that the event loop is not already running.

I guess that you could even wrap up Clint's suggestion in your own 
QApplication derived class.

Sean

clinton at elemtech.com wrote:
> Can you just use your own QEventLoop instead of QApplication::exec() ?
> Then you can do something like
> 
> QEventLoop eventLoop;
> while(eventloop.isRunning())
> {
>   eventloop.processEvents(QEventLoop::WaitForMoreEvents);
>   eventloop.processEvents();
>   MySpecialStuff();
> }
> 
> QApplication::exec just uses a QEventLoop to do the work.
> 
> The docs for QEventLoop::exec say "More sophisticated idle processing schemes can be achieved using processEvents()."
> 
> Clint
> 
> ----- Glenn Hughes <ghughes02138 at gmail.com> wrote:
>> Hi Sean, yes, that helps, 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.
>>
>> Thanks!
>> Glenn
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list