1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
'\" t
.TH QPtrCollection 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QPtrCollection \- The base class of most pointer-based TQt collections
.SH SYNOPSIS
All the functions in this class are reentrant when TQt is built with thread support.</p>
.PP
\fC#include <ntqptrcollection.h>\fR
.PP
Inherited by QAsciiCache, QAsciiDict, QCache, QDict, QIntCache, QIntDict, QPtrList, QPtrDict, and QPtrVector.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "bool \fBautoDelete\fR () const"
.br
.ti -1c
.BI "void \fBsetAutoDelete\fR ( bool enable )"
.br
.ti -1c
.BI "virtual uint \fBcount\fR () const = 0"
.br
.ti -1c
.BI "virtual void \fBclear\fR () = 0"
.br
.ti -1c
.BI "typedef void * \fBItem\fR"
.br
.in -1c
.SS "Protected Members"
.in +1c
.ti -1c
.BI "\fBQPtrCollection\fR ()"
.br
.ti -1c
.BI "\fBQPtrCollection\fR ( const QPtrCollection & source )"
.br
.ti -1c
.BI "virtual \fB~QPtrCollection\fR ()"
.br
.ti -1c
.BI "virtual Item \fBnewItem\fR ( Item d )"
.br
.ti -1c
.BI "virtual void \fBdeleteItem\fR ( Item d ) = 0"
.br
.in -1c
.SH DESCRIPTION
The QPtrCollection class is the base class of most pointer-based TQt collections.
.PP
The QPtrCollection class is an abstract base class for the TQt collection classes QDict, QPtrList, etc. TQt also includes value based collections, e.g. QValueList, QMap, etc.
.PP
A QPtrCollection only knows about the number of objects in the collection and the deletion strategy (see setAutoDelete()).
.PP
A collection is implemented using the Item (generic collection item) type, which is a \fCvoid*\fR. The template classes that create the real collections cast the Item to the required type.
.PP
See also Collection Classes and Non-GUI Classes.
.SS "Member Type Documentation"
.SH "QPtrCollection::Item"
This type is the generic "item" in a QPtrCollection.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QPtrCollection::QPtrCollection ()\fC [protected]\fR"
Constructs a collection. The constructor is protected because QPtrCollection is an abstract class.
.SH "QPtrCollection::QPtrCollection ( const QPtrCollection & source )\fC [protected]\fR"
Constructs a copy of \fIsource\fR with autoDelete() set to FALSE. The constructor is protected because QPtrCollection is an abstract class.
.PP
Note that if \fIsource\fR has autoDelete turned on, copying it will risk memory leaks, reading freed memory, or both.
.SH "QPtrCollection::~QPtrCollection ()\fC [virtual protected]\fR"
Destroys the collection. The destructor is protected because QPtrCollection is an abstract class.
.SH "bool QPtrCollection::autoDelete () const"
Returns the setting of the auto-delete option. The default is FALSE.
.PP
See also setAutoDelete().
.SH "void QPtrCollection::clear ()\fC [pure virtual]\fR"
Removes all objects from the collection. The objects will be deleted if auto-delete has been enabled.
.PP
See also setAutoDelete().
.PP
Reimplemented in QAsciiCache, QAsciiDict, QCache, QDict, QIntCache, QIntDict, QPtrList, QPtrDict, and QPtrVector.
.SH "uint QPtrCollection::count () const\fC [pure virtual]\fR"
Returns the number of objects in the collection.
.PP
Reimplemented in QAsciiCache, QAsciiDict, QCache, QDict, QIntCache, QIntDict, QPtrList, QPtrDict, and QPtrVector.
.SH "void QPtrCollection::deleteItem ( Item d )\fC [pure virtual protected]\fR"
Reimplement this function if you want to be able to delete items.
.PP
Deletes an item that is about to be removed from the collection.
.PP
This function has to reimplemented in the collection template classes, and should \fIonly\fR delete item \fId\fR if auto-delete has been enabled.
.PP
\fBWarning:\fR If you reimplement this function you must also reimplement the destructor and call the virtual function clear() from your destructor. This is due to the way virtual functions and destructors work in C++: Virtual functions in derived classes cannot be called from a destructor. If you do not do this, your deleteItem() function will not be called when the container is destroyed.
.PP
See also newItem() and setAutoDelete().
.SH "Item QPtrCollection::newItem ( Item d )\fC [virtual protected]\fR"
Virtual function that creates a copy of an object that is about to be inserted into the collection.
.PP
The default implementation returns the \fId\fR pointer, i.e. no copy is made.
.PP
This function is seldom reimplemented in the collection template classes. It is not common practice to make a copy of something that is being inserted.
.PP
See also deleteItem().
.SH "void QPtrCollection::setAutoDelete ( bool enable )"
Sets the collection to auto-delete its contents if \fIenable\fR is TRUE and to never delete them if \fIenable\fR is FALSE.
.PP
If auto-deleting is turned on, all the items in a collection are deleted when the collection itself is deleted. This is convenient if the collection has the only pointer to the items.
.PP
The default setting is FALSE, for safety. If you turn it on, be careful about copying the collection - you might find yourself with two collections deleting the same items.
.PP
Note that the auto-delete setting may also affect other functions in subclasses. For example, a subclass that has a remove() function will remove the item from its data structure, and if auto-delete is enabled, will also delete the item.
.PP
See also autoDelete().
.PP
Examples:
.)l grapher/grapher.cpp, scribble/scribble.cpp, and table/bigtable/main.cpp.
.SH "SEE ALSO"
.BR http://doc.trolltech.com/ntqptrcollection.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive TQt documentation is provided in HTML format; it is
located at $TQTDIR/doc/html and can be read using TQt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech.
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (tqptrcollection.3qt) and the Qt
version (3.3.8).
|