Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing slot on every application's event loop iteration

How can I call my slot on every iteration of application's event loop? Only way I know is to use QTimer and on every timeout (every millisecond) signal I can call my slot. But I don't like this option, it looks like workaround.

Any suggestions how to do this more correctly?

like image 222
asmodan Avatar asked Aug 23 '26 15:08

asmodan


1 Answers

From the Qt 4.7 QCoreApplication::exec() documentation:

To make your application perform idle processing (i.e. executing a special function whenever there are no pending events), use a QTimer with 0 timeout. More advanced idle processing schemes can be achieved using processEvents().

So your approach is what is prescribed. Look at QCoreApplication::processEvents() for more control over the event loop.

like image 61
Mat Avatar answered Aug 26 '26 05:08

Mat