📄 qptrcollection.3qt
字号:
'\" t.TH QPtrCollection 3qt "9 December 2002" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQPtrCollection \- The base class of most pointer-based Qt collections.SH SYNOPSISAll the functions in this class are reentrant when Qt is built with thread support.</p>.PP\fC#include <qptrcollection.h>\fR.PPInherited by QAsciiDict, QCache, QDict, QIntDict, QPtrList, QPtrDict, and QPtrVector..PP.SS "Public Members".in +1c.ti -1c.BI "bool \fBautoDelete\fR () const".br.ti -1c.BI "void \fBsetAutoDelete\fR ( bool enable )".br.ti -1c.BI "virtual uint \fBcount\fR () const = 0".br.ti -1c.BI "virtual void \fBclear\fR () = 0".br.ti -1c.BI "typedef void * \fBItem\fR".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "\fBQPtrCollection\fR ()".br.ti -1c.BI "\fBQPtrCollection\fR ( const QPtrCollection & source )".br.ti -1c.BI "virtual \fB~QPtrCollection\fR ()".br.ti -1c.BI "virtual Item \fBnewItem\fR ( Item d )".br.ti -1c.BI "virtual void \fBdeleteItem\fR ( Item d ) = 0".br.in -1c.SH DESCRIPTIONThe QPtrCollection class is the base class of most pointer-based Qt collections..PPThe 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..PPA QPtrCollection only knows about the number of objects in the collection and the deletion strategy (see setAutoDelete())..PPA 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..PPSee also Collection Classes and Non-GUI Classes..SS "Member Type Documentation".SH "QPtrCollection::Item"This type is the generic "item" in a QPtrCollection..SH MEMBER FUNCTION DOCUMENTATION.SH "QPtrCollection::QPtrCollection ()\fC [protected]\fR"Constructs a collection. The constructor is protected because QPtrCollection is an abstract class..SH "QPtrCollection::QPtrCollection ( const QPtrCollection & source )\fC [protected]\fR"Constructs a copy of \fIsource\fR with autoDelete() set to FALSE. The constructor is protected because QPtrCollection is an abstract class..PPNote that if \fIsource\fR has autoDelete turned on, copying it will risk memory leaks, reading freed memory, or both..SH "QPtrCollection::~QPtrCollection ()\fC [virtual protected]\fR"Destroys the collection. The destructor is protected because QPtrCollection is an abstract class..SH "bool QPtrCollection::autoDelete () const"Returns the setting of the auto-delete option. The default is FALSE..PPSee also setAutoDelete()..SH "void QPtrCollection::clear ()\fC [pure virtual]\fR"Removes all objects from the collection. The objects will be deleted if auto-delete has been enabled..PPSee also setAutoDelete()..PPReimplemented in QAsciiDict, QCache, QDict, QIntDict, QPtrList, QPtrDict, and QPtrVector..SH "uint QPtrCollection::count () const\fC [pure virtual]\fR"Returns the number of objects in the collection..PPReimplemented in QAsciiDict, QCache, QDict, 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..PPDeletes an item that is about to be removed from the collection..PPThis 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..PPSee 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..PPThe default implementation returns the \fId\fR pointer, i.e. no copy is made..PPThis function is seldom reimplemented in the collection template classes. It is not common practice to make a copy of something that is being inserted..PPSee also deleteItem()..SH "void QPtrCollection::setAutoDelete ( bool enable )"Sets the collection to auto-delete its contents if \fIenable\fR is TRUE and to never delete them if \fIenable\fR is FALSE..PPIf 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..PPThe 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..PPNote 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..PPSee also autoDelete()..PPExamples:.)l scribble/scribble.cpp and table/bigtable/main.cpp..SH "SEE ALSO".BR http://doc.trolltech.com/qptrcollection.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qptrcollection.3qt) and the Qtversion (3.1.1).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -