![]() |
| ||
Classes - Annotated - Tree - Functions - Home - Structure |
The QPtrCollection class is the base class of most value-based Qt collections. More...
#include <qptrcollection.h>
The QPtrCollection class is an abstract base class for the Qt collection classes QDict, QPtrList, etc.
A QPtrCollection knows only 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 void*. The template classes that create the real collections cast the Item to the required type.
See also Collection Classes.
This type is the generic "item" in a QPtrCollection.
Constructs a collection. The constructor is protected because QPtrCollection is an abstract class.
Constructs a copy of source with autoDelete() set to FALSE. The constructor is protected because QPtrCollection is an abstract class.
Note that if source has autoDelete turned on, copying it is a good way to get memory leaks, reading freed memory, or both.
Returns the setting of the auto-delete option. The default is FALSE.
See also setAutoDelete().
See also setAutoDelete().
Reimplemented in QGCache, QGDict and QGList.
Reimplemented in QGCache, QGDict and QGList.
The default implementation deletes d pointer if and only if auto-delete has been enabled.
This function is always reimplemented in the collection template classes.
Warning: 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 destructed.
See also newItem() and setAutoDelete().
The default implementation returns the d pointer, i.e., no copy is made.
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.
See also deleteItem().
Sets the collection to auto-delete its contents if enable is TRUE and to never delete them if enable is FALSE.
If auto-deleting is turned on, all the items in a collection are deleted when the collection itself is deleted. This can be quite convenient if the collection has the only pointer to the items.
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.
See also autoDelete().
Search the documentation, FAQ, qt-interest archive and more (uses
www.trolltech.com):
This file is part of the Qt toolkit, copyright © 1995-2001 Trolltech, all rights reserved.
Copyright © 2001 Trolltech | Trademarks | Qt version 3.0.0-beta1-beta1
|