[Qt-interest] Is there a way to process all queued events before continuing?
Preet
preet.desai at gmail.com
Wed Dec 16 17:49:52 CET 2009
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/ad583e8d/attachment.html
More information about the Qt-interest-old
mailing list