QCollection - The base class of all Qt collections
#include <qcollection.h>
Inherited by QGCache, QGDict, QGList and QGVector.
Public Members
bool autoDelete () const
void setAutoDelete ( bool enable )
virtual uint count () const
virtual void clear ()
typedef void* Item
Protected Members
QCollection ()
QCollection ( const QCollection & )
virtual ~QCollection ()
virtual Item newItem ( Item )
virtual void deleteItem ( Item )
DESCRIPTION
The QCollection class is the base class of all Qt
collections.
The QCollection class is an abstract base class for the Qt
collection classes QDict, QList etc. via QGDict, QGList
etc.
A QCollection 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
Member Type Documentation
QCollection::Item
This type is the generic "item" in a QCollection.
MEMBER FUNCTION DOCUMENTATION
QCollection::QCollection () [protected]
Constructs a collection. The constructor is protected
because QCollection is an abstract class.
QCollection::QCollection ( const QCollection & source )
[protected]
Constructs a copy of source with autoDelete() set to
FALSE. The constructor is protected because QCollection is
Note that if source has autoDelete turned on, copying it
is a good way to get memory leaks, reading freed memory,
or both.
QCollection::~QCollection () [virtual protected]
Destroys the collection. The destructor is protected
because QCollection is an abstract class.
bool QCollection::autoDelete () const
Returns the setting of the auto-delete option (default is
FALSE).
See also setAutoDelete().
virtual void QCollection::clear () [virtual]
Removes all objects from the collection. The objects will
be deleted if auto-delete has been enabled.
See also setAutoDelete().
Reimplemented in QGCache, QIntDict, QDict, QPtrDict,
QAsciiDict, QQueue, QGVector, QAsciiCache, QStack,
QVector, QList, QGDict, QGList, QIntCache and QCache.
virtual uint QCollection::count () const [virtual]
Returns the number of objects in the collection.
Reimplemented in QGDict, QGList, QAsciiCache, QGCache,
QVector, QPtrDict, QIntCache, QDict, QAsciiDict, QCache,
QQueue, QGVector, QIntDict, QList and QStack.
void QCollection::deleteItem ( Item d ) [protected]
Virtual function that deletes an item that is about to be
removed from the collection.
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().
Virtual function that creates a copy of an object that is
about to be inserted into the collection.
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().
void QCollection::setAutoDelete ( bool enable )
Sets the auto-delete option of the collection.
Enabling auto-delete (enable is TRUE) will delete objects
that are removed from the collection. This can be useful
if the collection has the only reference to the objects.
(Note that the object can still be copied using the copy
constructor - copying such objects is a good way to get
memory leaks, reading freed memory or both.)
Disabling auto-delete (enable is FALSE) will not delete
objects that are removed from the collection. This is
useful if the objects are part of many collections.
The default setting is FALSE.
See also autoDelete().
Examples: grapher/grapher.cpp
SEE ALSO
http://doc.trolltech.com/qcollection.html
http://www.trolltech.com/faq/tech.html
COPYRIGHT
Copyright 1992-2001 Trolltech AS,
http://www.trolltech.com. See the license file included
in the distribution for a complete license statement.
AUTHOR
Generated automatically from the source code.
BUGS
If you find a bug in Qt, please report it as described in
http://doc.trolltech.com/bughowto.html. Good bug reports
make our job much simpler. Thank you.
In case of content or formattting problems with this
manual page, please report them to qt-bugs@trolltech.com.
Please include the name of the manual page
(qcollection.3qt) and the Qt version (2.3.1).
Man(1) output converted with
man2html