QPtrCollection(3qt)

πŸ“¦ version 3.3.8b, in fedora 43, fedora 44

πŸ’– QPtrCollection β€” the qptrcollection.3qt era, bestie πŸ’–

okay so. sit down. hydrate. we're talking about QPtrCollection, from the Qt 3.3.8 man pages (Trolltech, 2 February 2007, the good stuff) β€” and I promise this is gonna be more fun than it sounds. πŸŽ€


✨ NAME ✨

QPtrCollection β€” the base class of most pointer-based Qt collections. she's the mom. the blueprint. the blueprint mom. πŸ’…


🌸 SYNOPSIS 🌸

All the functions in this class are reentrant when Qt is built with thread support. (the original literally has a stray </p> in there and we respect it anyway. iconic.) πŸ¦‹

#include <qptrcollection.h>

Inherited by QAsciiCache, QAsciiDict, QCache, QDict, QIntCache, QIntDict, QPtrList, QPtrDict, and QPtrVector. (nine whole children. mother is mothering.) πŸ‘‘

πŸ’œ Public Members πŸ’œ

bool autoDelete () const
void setAutoDelete ( bool enable )
virtual uint count () const = 0
virtual void clear () = 0
typedef void * Item

🫢 Protected Members 🫢

QPtrCollection ()
QPtrCollection ( const QPtrCollection & source )
virtual ~QPtrCollection ()
virtual Item newItem ( Item d )
virtual void deleteItem ( Item d ) = 0

🌈 DESCRIPTION 🌈

The QPtrCollection class is the base class of most pointer-based Qt collections. no cap.

QPtrCollection is an abstract base class for the Qt collection classes QDict, QPtrList, etc. Qt also includes value based collections, e.g. QValueList, QMap, etc. (two different species, don't mix them up bestie 😭)

A QPtrCollection only knows about two things, and honestly? relatable:

  • the number of objects in the collection
  • 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. it's giving casting energy. ✨

See also Collection Classes and Non-GUI Classes.


🧚 Member Type Documentation 🧚

QPtrCollection::Item

This type is the generic "item" in a QPtrCollection. that's it. that's the whole type. a void* with main character energy. πŸ’«


πŸ‘‘ MEMBER FUNCTION DOCUMENTATION πŸ‘‘

QPtrCollection::QPtrCollection () [protected]

Constructs a collection. The constructor is protected because QPtrCollection is an abstract class. (you can't just summon her, she's abstract, respect the boundary πŸ™ˆ)

QPtrCollection::QPtrCollection ( const QPtrCollection & source ) [protected]

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 auto-delete turned on, copying it will risk memory leaks, reading freed memory, or both. bestie. BESTIE. do not do this. πŸ’€

QPtrCollection::~QPtrCollection () [virtual protected]

Destroys the collection. The destructor is protected because QPtrCollection is an abstract class.

bool QPtrCollection::autoDelete () const

Returns the setting of the auto-delete option. The default is FALSE. (safety first, always 🌸)

See also setAutoDelete().

void QPtrCollection::clear () [pure virtual]

Removes all objects from the collection. The objects will be deleted if auto-delete has been enabled. so it depends. it always depends. 😭

See also setAutoDelete().

Reimplemented in QAsciiCache, QAsciiDict, QCache, QDict, QIntCache, QIntDict, QPtrList, QPtrDict, and QPtrVector.

uint QPtrCollection::count () const [pure virtual]

Returns the number of objects in the collection. just the number. the vibe check of quantity. πŸ”’

Reimplemented in QAsciiCache, QAsciiDict, QCache, QDict, QIntCache, QIntDict, QPtrList, QPtrDict, and QPtrVector.

void QPtrCollection::deleteItem ( Item d ) [pure virtual protected]

Reimplement this function if you want to be able to delete items. (only if you want to be able to. no pressure. but like. do it.) πŸ’…

Deletes an item that is about to be removed from the collection.

This function has to reimplemented in the collection template classes, and should only delete item d if auto-delete has been enabled.

🚨 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 destroyed. (read that twice. I'm serious. this is the plot twist of the whole page. 😳)

See also newItem() and setAutoDelete().

Item QPtrCollection::newItem ( Item 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. simple. clean. no duplicate drama. ✨

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. (and honestly? valid.)

See also deleteItem().

void QPtrCollection::setAutoDelete ( bool enable )

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 is 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. double deletion. the horror. πŸ’€

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.

See also autoDelete().

Examples: β€” and then the manpage just says that and dips. no examples. nothing. a whole bullet point of silence. πŸ˜­πŸ™ˆ (preserving it exactly, bestie, because that's the rule)


πŸ”₯ SEE ALSO πŸ”₯


Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.


πŸ’œ AUTHOR πŸ’œ

Generated automatically from the source code. (no human author to thank. the machine did it. we stan an automated queen. πŸ€–πŸ‘‘)


πŸ¦‹ BUGS πŸ¦‹

If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. 🫢

The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt 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. (she's a convenience, not a contract, iykyk)

If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qptrcollection.3qt) and the Qt version (3.3.8).


okay that's the whole thing, you made it, I'm so proud of you πŸ’– this page came from Trolltech AS, dated 2 February 2007, and it's the QPtrCollection(3qt) page from Qt 3.3.8 β€” go forth and reimplement that destructor, bestie, no cap. πŸŽ€βœ¨πŸ¦‹πŸ’…

πŸ“¦ where this page comes from