When should I use QObject::deleteLater() instead of delete ?
-
When should I use QObject::deleteLater() instead of delete ?
-
delete directly delete the object. But if some events are pending on event loop to be performed for the same OBJECT, then <delete> may give you a crash, but deleteLater() is safe to use in this case.
Because, deleteLater() will delete the object only when all pending events for the same object are finished. So it is better practice to not use the object after deleteLater(), because you don't know when the object is get deleted.
I think it helps..cheers..