[Qt-interest] QEventLoop and QEvents

Bradley T. Hughes bradley.hughes at nokia.com
Mon Feb 22 16:53:33 CET 2010


On 02/22/2010 04:25 PM, Eric Clark wrote:
> I thought that an event loop used a queue to store the events until
> processEvents was called on it... Is this incorrect? If I never call exec
> on the event loop, will it not store the events that I post to it until I
> either call exec or processEvents?

This is partially correct. Qt uses a per-thread queue of events for 
programatically generated events (this is where the events posted with 
QApplication::postEvent() go). There is also the per-thread system queue, 
which is processed when ever processEvents() is called.

However, QEventLoop is nothing more than an interface to the event 
processing mechanism. It doesn't actually manage the queue, Qt does this in 
QApplication and QEventDispatcher* (the internal implementations of the 
various platforms event dispatching mechanisms). QEventLoop::exec() and 
processEvents() are just wrappers around the above to actually do the event 
dispatching.

-- 
Bradley T. Hughes (Nokia-D-Qt/Oslo), bradley.hughes at nokia.com
Sandakervn. 116, P.O. Box 4332 Nydalen, 0402 Oslo, Norway



More information about the Qt-interest-old mailing list