QObjectCleanupHandler

The QObjectCleanupHandler class watches the lifetime of multiple QObjects. More...

 #include <QObjectCleanupHandler>

Inherits: QObject.

Public Functions

QObjectCleanupHandler ()
~QObjectCleanupHandler ()
QObject * add ( QObject * object )
void clear ()
bool isEmpty () const
void remove ( QObject * object )

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 signal inherited from QObject
  • 7 static public members inherited from QObject
  • 8 protected functions inherited from QObject

Detailed Description

The QObjectCleanupHandler class watches the lifetime of multiple QObjects.

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.

To keep track of some QObjects, 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() returns true if the QObjectCleanupHandler has no objects to keep track of.

See also QPointer.

Last modified: 2014-03-13

comments powered by Disqus