PDA

View Full Version : Does QCoreApplication::processEvents call posted events processing ?



burkav84
19th February 2007, 20:26
My questions are:
1. Does void QCoreApplication:: processEvents ( QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents ) or void QCoreApplication:: processEvents ( QEventLoop:: ProcessEventsFlags flags, int maxtime ) call events processing posted by QCoreApplication:: postEvent() ?
2. Can void QCoreApplication:: processEvents call the event processing posted from a thred (connected by Qt::QueuedConnection) ?
Thanks.

jacek
19th February 2007, 20:43
QCoreApplication::processEvents() processes events only from the GUI thread's queue, that is all events what where sent to it, not those which were sent from the GUI thread.

burkav84
20th February 2007, 09:31
So, if I post event from the non-gui thread by QCoreApplication:: postEvent or emit signal from QThread:: run, connnected as Qt:: QueuedConnection it will not process while gui thread won't return to the QApplication event loop or will be processed if I make it force by QCoreApplication:: sendPostedEvents. If I call QCoreApplication:: processEvents(...) it will NOT cause posted events processing, only paint events, timer and so on ?

jpn
20th February 2007, 11:07
So, if I post event from the non-gui thread by QCoreApplication:: postEvent or emit signal from QThread:: run, connnected as Qt:: QueuedConnection it will not process while gui thread won't return to the QApplication event loop or will be processed if I make it force by QCoreApplication:: sendPostedEvents. If I call QCoreApplication:: processEvents(...) it will NOT cause posted events processing, only paint events, timer and so on ?
It doesn't matter where the event is posted (or a queued signal is emitted) from. What does matter is where the receiver object lives.

If the receiver lives in the main thread (*), the event gets added to the event queue of the main thread. QCoreApplication::processEvents() is there for processing pending events from the main thread's event queue and is not safe to be called from another thread than the main thread.

(*) with "main thread" I mean the same thread where the application object lives

wysota
20th February 2007, 12:35
Maybe a short answer is needed - QCoreApplication::processEvents() called without parameters processes all types of events that are in the queue. Paint events, timer events, etc. are also posted, so there is no such thing as differenciating between "posted" and "other" events unless by "other" you mean spontaneous, but I'm sure they also get into the queue by using postEvent.