QObjectCleanupHandler 类看守多个 QObject 的寿命。 更多...
头: | #include <QObjectCleanupHandler> |
qmake: | QT += core |
继承: | QObject |
QObjectCleanupHandler () | |
virtual | ~QObjectCleanupHandler () |
QObject * | add (QObject * object ) |
void | clear () |
bool | isEmpty () const |
void | remove (QObject * object ) |
A QObjectCleanupHandler is useful whenever you need to know when a number of QObject s that are owned by someone else have been deleted. This is important, for example, when referencing memory in an application that has been allocated in a shared library.
To keep track of some
QObject
s, create a QObjectCleanupHandler, and
add
() the objects you are interested in. If you are no longer interested in tracking a particular object, use
remove
() to remove it from the cleanup handler. If an object being tracked by the cleanup handler gets deleted by someone else it will automatically be removed from the cleanup handler. You can delete all the objects in the cleanup handler with
clear
(), or by destroying the cleanup handler.
isEmpty
() 返回
true
if the QObjectCleanupHandler has no objects to keep track of.
另请参阅 QPointer .
构造空的 QObjectCleanupHandler。
[虚拟]
QObjectCleanupHandler::
~QObjectCleanupHandler
()
Destroys the cleanup handler. All objects in this cleanup handler will be deleted.
另请参阅 clear ().
添加 object to this cleanup handler and returns the pointer to the object.
另请参阅 remove ().
Deletes all objects in this cleanup handler. The cleanup handler becomes empty.
另请参阅 isEmpty ().
返回
true
if this cleanup handler is empty or if all objects in this cleanup handler have been destroyed; otherwise return false.
另请参阅 add (), remove (),和 clear ().
移除 object from this cleanup handler. The object will not be destroyed.
另请参阅 add ().