[Development] [Q] Good way to handle QEvent::DeferredDelete

Elvis Lee(KwangWoong Lee) kwangwoong.lee at lge.com
Fri Dec 27 03:23:39 CET 2013



I'm looking for good way to handle objects which have called deleteLater.

According to what I understood until now, there are 2 ways to handle them.

One is making control return to the event loop. Another is calling
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete) explicitly.


Actually, for the first way, I couldn't know what to do exactly in code
level. How to return control to event loop?

I feel the control is always on event loop in our module. Does that mean to
exit from event loop in QCoreApplication::exec()?


So I tried the second way, calling sendPostedEvents explicitly. But I
encountered an obstacle to send the event.

It seems that the function should be called with lower or same 'loopLevel'
of posted event.

I couldn't find proper position to call sendPostedEvents except adding glib
function to main event loop. (We are using qeventdispatcher_glib)

Usually where is the good position to call sendPostedEvents with low


In sum, there are 2 question.

1.     What is the natural way to handle deleteLater?

2.     Where is a place which is not from QCoreApplication::notifyInternal
so that it has loopLevel '1' to call sendPostedEvents?




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20131227/58c90e64/attachment.html>

More information about the Development mailing list