The QObjectCleanupHandler class watches the lifetime of multiple QObjects.
.PP
A QObjectCleanupHandler is useful whenever you need to know when a number of QObjects 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.
.PP
Example:
.PP
.nf
.br
class FactoryComponent : public FactoryInterface, public QLibraryInterface
.br
{
.br
public:
.br
...
.br
.br
QObject *createObject();
.br
.br
bool init();
.br
void cleanup();
.br
bool canUnload() const;
.br
.br
private:
.br
QObjectCleanupHandler objects;
.br
};
.br
.br
// allocate a new object, and add it to the cleanup handler
.br
QObject *FactoryComponent::createObject()
.br
{
.br
return objects.add( new QObject() );
.br
}
.br
.br
// QLibraryInterface implementation
.br
bool FactoryComponent::init()
.br
{
.br
return TRUE;
.br
}
.br
.br
void FactoryComponent::cleanup()
.br
{
.br
}
.br
.br
// it is only safe to unload the library when all QObject's have been destroyed