[Qt-interest] sendPostedEvents() does not dispatch all events
Nikos Chantziaras
realnc at arcor.de
Thu Apr 29 18:13:54 CEST 2010
Since the documentation of QCoreApplication::processEvents() states that:
"In event you are running a local loop which calls this function
continuously, without an event loop, the DeferredDelete events
will not be processed. [...] An alternative would be to call
sendPostedEvents() from within that local loop."
However, deleting a QObject with:
someObj->deleteLater();
and then doing:
qApp->sendPostedEvents();
does not result in 'someObj' being deleted. For that to happen, I have
to explicitly call:
qApp->sendPostedEvents(0, QEvent::DeferredDelete);
Is this a bug or expected behavior? The documentation of
sendPostedEvents() would suggest that simply all events are dispatched,
and does not state any exceptions (like DeferredDelete).
In my case, the local loop happens inside the QCoreApplication main
event loop; that is, after a call to app->exec(). The local loop does
some processing and calls:
qApp->sendPostedEvents();
qApp->processEvents();
to keep the GUI responsive. But it seems I have to call
"qApp->sendPostedEvents(0, QEvent::DeferredDelete)" in addition, since
QWidget subclasses in that local loop are deleted with deleteLater().
I'd just like to know why that is, and why "qApp->sendPostedEvents()"
doesn't dispatch the DeferredDeletes.
More information about the Qt-interest-old
mailing list