[slot] void QObject::deleteLater()

Schedules this object for deletion.

The object will be deleted when control returns to the event loop. If the event loop is not running when this function is called (e.g. deleteLater() is called on an object before QCoreApplication::exec()), the object will be deleted once the event loop is started. If deleteLater() is called after the main event loop has stopped, the object will not be deleted. Since Qt 4.8, if deleteLater() is called on an object that lives in a thread with no running event loop, the object will be destroyed when the thread finishes.

计划这个对象的删除。

这句不懂。如果当这个函数被调用的时候,事件循环还没有执行的话(例如:deleteLater()在QCoreApplication::exec()之前按被一个对象调用的话),当这个事件循环开始的时候,这个对象会立刻被删除。如果deleteLater()在main事件循环停止后被调用的话,这个对象不会被删除。从Qt4.8开始,如果deleteLater()被一个对象调用,而这个对象在一个没有循环事件的线程中的话,这个对象会在线程结束时被消灭

Note: It is safe to call this function more than once; when the first deferred deletion event is delivered, any pending events for the object are removed from the event queue.

注释:多次调用这个函数是安全的;当第一个被延迟的删除事件被传递的时候,任何和这个对象有关的在等待的事件都会被从事件队列中删除。

 

posted @ 2020-05-23 16:22  郭朋振  阅读(358)  评论(0编辑  收藏  举报