[Qt-interest] Is there a way to process all queued events before continuing?

Bradley T. Hughes bradley.hughes at nokia.com
Wed Dec 16 17:46:47 CET 2009


Andre Somers wrote:
> Preet wrote:
>> Hi,
>>
>> Thanks for the reply. I'm trying to clear all pending events in my 
>> secondary thread's event queue. Doesn't processEvents do this for my 
>> main Gui thread? (not what I want to do). There's no 
>> QThread::ProcessEvents() function... I'm looking for such an analog.
>>
>> -Preet
> Interesting question. QEventLoop has a processEvents, but I don't see a 
> method in QThread to access the thread's event loop... Perhaps the 
> source could give you a pointer if there is an (undocumented) loophope 
> to get it anyway?

I'll do you one better, here's how do to it (and it's documented):

http://qt.nokia.com/doc/4.6/qcoreapplication.html#processEvents

"void QCoreApplication::processEvents ( QEventLoop::ProcessEventsFlags flags 
= QEventLoop::AllEvents )   [static]

Processes all pending events for the calling thread according to the 
specified flags until there are no more events to process."

-- 
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