QCollection Class Reference


This is the base class of all Qt collections. More...

#include <qcollect.h>

Inherited by QGCache, QGDict and QGList.

List of all member functions.

Public Members

Protected Members


Detailed Description

This 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.

A collection is implemented using the GCI (generic collection item) type, which is a void*. The template (or macro) classes that create the real collections cast the GCI to the required type.

See also: Collection Classes


Member Function Documentation

QCollection::QCollection () [protected]

Constructs a collection. The constructor is protected because QCollection is an abstract class.

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 QGDict, QList, QPtrDict, QGCache, QDict, QIntDict and QGList.

virtual uint QCollection::count () const [virtual]

Returns the number of objects in the collection.

Reimplemented in QList, QPtrDict, QGCache, QDict, QGList, QIntDict and QGDict.

void QCollection::deleteItem ( GCI d ) [virtual 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.

See also: newItem() and setAutoDelete().

GCI QCollection::newItem ( GCI d ) [virtual protected]

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.

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().


This file is part of the Qt toolkit, copyright © 1995-97 Troll Tech, all rights reserved.

It was generated from the following files:


Generated at 19:08, 1997/10/09 for Qt version 1.31 by the webmaster at Troll Tech