.BI "virtual void \fBdeleteItem\fR ( Item d ) = 0"
.br
.in -1c
.SH DESCRIPTION
The QPtrCollection class is the base class of most pointer-based Qt collections.
.PP
The QPtrCollection class is an abstract base class for the Qt collection classes QDict, QPtrList, etc. Qt 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()).
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.
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.
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.