1QObjectCleanupHandler(3qt) QObjectCleanupHandler(3qt)
2
3
4
6 QObjectCleanupHandler - Watches the lifetime of multiple QObjects
7
9 #include <qobjectcleanuphandler.h>
10
11 Inherits QObject.
12
13 Public Members
14 QObjectCleanupHandler ()
15 ~QObjectCleanupHandler ()
16 QObject * add ( QObject * object )
17 void remove ( QObject * object )
18 bool isEmpty () const
19 void clear ()
20
22 The QObjectCleanupHandler class watches the lifetime of multiple
23 QObjects.
24
25 A QObjectCleanupHandler is useful whenever you need to know when a
26 number of QObjects that are owned by someone else have been deleted.
27 This is important, for example, when referencing memory in an
28 application that has been allocated in a shared library.
29
30 Example:
31
32 class FactoryComponent : public FactoryInterface, public QLibraryInterface
33 {
34 public:
35 ...
36 QObject *createObject();
37 bool init();
38 void cleanup();
39 bool canUnload() const;
40 private:
41 QObjectCleanupHandler objects;
42 };
43 // allocate a new object, and add it to the cleanup handler
44 QObject *FactoryComponent::createObject()
45 {
46 return objects.add( new QObject() );
47 }
48 // QLibraryInterface implementation
49 bool FactoryComponent::init()
50 {
51 return TRUE;
52 }
53 void FactoryComponent::cleanup()
54 {
55 }
56 // it is only safe to unload the library when all QObject's have been destroyed
57 bool FactoryComponent::canUnload() const
58 {
59 return objects.isEmpty();
60 }
61
62 See also Object Model.
63
66 Constructs an empty QObjectCleanupHandler.
67
69 Destroys the cleanup handler. All objects in this cleanup handler will
70 be deleted.
71
73 Adds object to this cleanup handler and returns the pointer to the
74 object.
75
77 Deletes all objects in this cleanup handler. The cleanup handler
78 becomes empty.
79
81 Returns TRUE if this cleanup handler is empty or if all objects in this
82 cleanup handler have been destroyed; otherwise return FALSE.
83
85 Removes the object from this cleanup handler. The object will not be
86 destroyed.
87
88
90 http://doc.trolltech.com/qobjectcleanuphandler.html
91 http://www.trolltech.com/faq/tech.html
92
94 Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
95 license file included in the distribution for a complete license
96 statement.
97
99 Generated automatically from the source code.
100
102 If you find a bug in Qt, please report it as described in
103 http://doc.trolltech.com/bughowto.html. Good bug reports help us to
104 help you. Thank you.
105
106 The definitive Qt documentation is provided in HTML format; it is
107 located at $QTDIR/doc/html and can be read using Qt Assistant or with a
108 web browser. This man page is provided as a convenience for those users
109 who prefer man pages, although this format is not officially supported
110 by Trolltech.
111
112 If you find errors in this manual page, please report them to qt-
113 bugs@trolltech.com. Please include the name of the manual page
114 (qobjectcleanuphandler.3qt) and the Qt version (3.3.8).
115
116
117
118Trolltech AS 2 February 2007 QObjectCleanupHandler(3qt)