There is only one event loop (per thread). QEventLoop only provides a different entry point to the existing event loop. Events do not care if they are handled as a result of QEventLoop::exec() or QCoreApplication::exec(). The only difference is that calling exec() on QEventLoop bumps up an internal level counter in the event loop which cares that deferred delete (aka QObject::deleteLater()) is executed on the same (or lower) level at which the delete was scheduled. In other words, if you do this:
Qt Code:
obj->deleteLater(); QEventLoop loop; loop.exec(); bool b = obj->isStillThere();To copy to clipboard, switch view to plain text mode
"obj" is still valid after loop.exec() returns.
Bookmarks