| Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |
The QObjectCleanupHandler class watches the lifetime of multiple QObjects. More...
#include <qobjectcleanuphandler.h>
Inherits QObject.
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.
Example:
class FactoryComponent : public FactoryInterface, public QLibraryInterface
{
public:
...
QObject *createObject();
bool init();
void cleanup();
bool canUnload() const;
private:
QObjectCleanupHandler objects;
};
// allocate a new object, and add it to the cleanup handler
QObject *FactoryComponent::createObject()
{
return objects.add( new QObject() );
}
// QLibraryInterface implementation
bool FactoryComponent::init()
{
return TRUE;
}
void FactoryComponent::cleanup()
{
}
// it is only safe to unload the library when all QObject's have been destroyed
bool FactoryComponent::canUnload() const
{
return objects.isEmpty();
}
See also Object Model.
This file is part of the Qt toolkit. Copyright © 1995-2005 Trolltech. All Rights Reserved.
| Copyright © 2005 Trolltech | Trademarks | Qt 3.3.5
|