QEventLoop and QCoreApplication::processEvents
-
Well QEventLoop is a local event loop so
there exists 2 at that moment in time while
"processEvents" just drives the default one.Its best if you can design your application so no local waiting is needed. :)
-
@beecksche said in QEventLoop and QCoreApplication::processEvents:
is there i difference
Yes, a huge difference. For one
QEventLoop::exec
is a "blocking" call, which means it will stop at that position and sleep until there are events to process. Finally if there's a call toQEventLoop::quit
(through a signal-slot connection) it will return control to the user code.On the other hand
QCoreApplication::processEvents()
will process as many events there are in the event loop at the time of call and return control to the user code immediately (on first possible occasion).@mrjj said in QEventLoop and QCoreApplication::processEvents:
Well QEventLoop is a local event loop
Eh, mostly yes. The distinction is made by a single integer that counts the "nest level" of event loops. And as recently discussed in another thread the "local" event loop will spin the global one too. Actually, beside some tweaks like the
QCoreApplication::aboutToQuit
signal,QCoreApplication::exec
just callsQEventLoop::exec
.