[Qt-interest] Is there a way to process all queued eventsbefore continuing?
Scott Aron Bloom
Scott.Bloom at sabgroup.com
Wed Dec 16 17:55:08 CET 2009
One thing you might try...
If you are trying to tell a worker thread "process everything", you cant
call the qapp->processEvents since that only works on the calling
thread..
Create a slot on the worker thread, then connect to it in Blocking
manner, and send a "process all" type of signal
Scott
From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Preet
Sent: Wednesday, December 16, 2009 8:50 AM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] Is there a way to process all queued
eventsbefore continuing?
One thing that is briefly mentioned in the docs is to call
QTimer::singleShot with a timeout of zero. This is supposed to 'timeout'
after all pending events are processed. I'd appreciate if someone could
expand on this... what happens exactly -- is the QTimer event simply
posted to the end of the current event queue?
I have a QThread servicing a device which constantly tacks on events to
its event queue. To 'block' the thread, I block the device, but during
the interim between the call to block the device, and it actually being
executed, more events may be placed on the queue. I need to process
these additional events before I can continue. I'll update this if
QTimer works as expected.
edit:
I just got your reply Bradley, I'll give it a shot.
Thanks all!
On Wed, Dec 16, 2009 at 11:46 AM, Bradley T. Hughes
<bradley.hughes at nokia.com> wrote:
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
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091216/a4b2b89e/attachment.html
More information about the Qt-interest-old
mailing list