QDictIterator(3qt)

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

πŸ’… QDictIterator β€” ok bestie, it's the QDictIterator(3qt) page ✨


🌸 NAME 🌸

QDictIterator β€” the iterator for QDict collections. that's it, that's the job. 🫢


✨ SYNOPSIS ✨

#include <qdict.h>

πŸŽ€ Public Members πŸŽ€

QDictIterator ( const QDict<type> & dict )
~QDictIterator ()
uint count () const
bool isEmpty () const
type * toFirst ()
operator type * () const
type * current () const
QString currentKey () const
type * operator() ()
type * operator++ ()

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so. the QDictIterator class hands you an iterator for QDict collections. that's the whole vibe. πŸ‘‘

QDictIterator is a template class, bestie. you define a template instance QDictIterator<X> to create a dictionary iterator that operates on QDict<X> β€” which is, say it with me, a dictionary of X*. no cap.

the traversal order is arbitrary. so when we say "first", "last" and "next" item, we're literally just talking in terms of that arbitrary order. it's giving ✨chaos✨ but make it functional.

Multiple iterators may independently traverse the same dictionary. a QDict knows about all the iterators that are operating on the dictionary. so when an item gets removed from the dictionary, QDict updates all iterators that are referring to the removed item to point to the next item in the (arbitrary) traversal order. not me being looked after by my own data structure πŸ˜­πŸ’–

example time, stay with me:

QDict<QLineEdit> fields;
fields.insert( "forename", new QLineEdit( this ) );
fields.insert( "surname", new QLineEdit( this ) );
fields.insert( "age", new QLineEdit( this ) );
fields["forename"]->setText( "Homer" );
fields["surname"]->setText( "Simpson" );
fields["age"]->setText( "45" );
QDictIterator<QLineEdit> it( fields );
for( ; it.current(); ++it )
    cout << it.currentKey() << ": " << it.current()->text() << endl;
cout << endl;
// Output (random order):
//  age: 45
//  surname: Simpson
//  forename: Homer

so in the example we insert some pointers to line edits into a dictionary, then iterate over the dictionary printing the strings associated with the line edits. iconic behaviour honestly.

see also QDict, Collection Classes, and Non-GUI Classes. 🫢


πŸ‘‘ MEMBER FUNCTION DOCUMENTATION πŸ‘‘

QDictIterator::QDictIterator ( const QDict<type> & dict )

constructs an iterator for dict. the current iterator item is set to point to the first item in the dictionary, dict. and "first" in this context means first in the arbitrary traversal order. yes we're saying it again. it matters. πŸ’…

QDictIterator::~QDictIterator ()

destroys the iterator. bye bestie πŸ¦‹βœ¨

uint QDictIterator::count () const

returns the number of items in the dictionary over which the iterator is operating. how many little guys are in there. πŸ”’

see also isEmpty().

type * QDictIterator::current () const

returns a pointer to the current iterator item's value. that's your main character right there. 🌟

QString QDictIterator::currentKey () const

returns the current iterator item's key. πŸŽ€

bool QDictIterator::isEmpty () const

returns TRUE if the dictionary is empty β€” i.e. count() == 0 β€” otherwise returns FALSE. empty dict era πŸ’€

see also count().

QDictIterator::operator type * () const

cast operator. returns a pointer to the current iterator item. same as current(). literally the same thing, no notes. 🫢

type * QDictIterator::operator() ()

makes the next item current and returns the original current item. okay so it's moving forward but handing you what was there before, so rude but useful.

if the current iterator item was the last item in the dictionary or if it was 0, 0 is returned. that's it. that's the deal.

type * QDictIterator::operator++ ()

prefix ++ makes the next item current and returns the new current item. glow-up moment. ✨

if the current iterator item was the last item in the dictionary or if it was 0, 0 is returned.

type * QDictIterator::toFirst ()

resets the iterator, making the first item the first current item. and "first" in this context means first in the arbitrary traversal order β€” yes, again, we know, it's load-bearing. returns a pointer to this item.

if the dictionary is empty it sets the current item to 0 and returns 0. πŸ•³οΈ


🌈 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. yes, a robot wrote this, and it ate. πŸ€–πŸ’…


πŸ™ˆ 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. 🫢 (fr fr, they mean it)

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. πŸ’€

if you find errors in this manual page, please report them to qt-bugs@trolltech.com. please include the name of the manual page (qdictiterator.3qt) and the Qt version (3.3.8). please bestie, include the version, it saves everyone's life. 😭


and that's the whole page, mwah πŸ’‹ Trolltech AS, 2 February 2007, Qt vibes β€” go forth and iterate, you've got this βœ¨πŸŽ€πŸ¦‹πŸ‘‘
πŸ“¦ where this page comes from