PDA

View Full Version : How to log returning control back to the main event loop?



piotr.dobrogost
27th September 2009, 20:18
Is there any way to log when program returns control back to the main event loop?

wysota
27th September 2009, 20:42
You can reimplement QCoreApplication::notify() which is a method called for every event dispatch in your application. An alternative is to install an event filter on the application object which gives you a similar possibility just without subclassing.

piotr.dobrogost
28th September 2009, 08:48
typedef QCoreApplication::EventFilter
A function with the following signature that can be used as an event filter:
bool myEventFilter(void *message, long *result);

I guess every message should have at least some kind of an id. Is there any way to get message's id from message argument on Windows?

wysota
28th September 2009, 08:52
This is for Windows events... If you want Qt events, use QObject::installEventFilter() and QObject::eventFilter().

piotr.dobrogost
28th September 2009, 08:55
You can reimplement QCoreApplication::notify() which is a method called for every event dispatch in your application. An alternative is to install an event filter on the application object which gives you a similar possibility just without subclassing.

Let's say I'm interested in logging the fact of entering the main event loop only. I'm not interested in what and how many events are processed after entering the loop. Any idea how to go about implementing this?

wysota
28th September 2009, 09:57
A full implementation would require reimplementing QAbstractEventDispatcher::processEvents() but I assume you wouldn't like to do that thus it's best to track event dispatching as suggested.