1
<?xml version="1.0" encoding="iso-8859-1"?>
3
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/doc/src/q3dict.qdoc -->
7
<title>Qt 4.0: Q3DictIterator Class Reference</title>
8
<style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
9
a:link { color: #004faf; text-decoration: none }
10
a:visited { color: #672967; text-decoration: none }
11
td.postheader { font-family: sans-serif }
12
tr.address { font-family: sans-serif }
13
body { background: #ffffff; color: black; }</style>
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
19
<td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="mainclasses.html"><font color="#004faf">Main Classes</font></a> · <a href="annotated.html"><font color="#004faf">Annotated</font></a> · <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td>
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">Q3DictIterator Class Reference</h1>
21
<p>The Q3DictIterator class provides an iterator for <a href="q3dict.html">Q3Dict</a> collections. <a href="#details">More...</a></p>
22
<pre>#include <Q3DictIterator></pre><p><b>This class is part of the Qt 3 support library.</b> It is provided to keep old source code working. We strongly advise against using it in new code. See the <a href="porting4.html">Porting Guide</a> for more information.</p>
23
<p>Part of the <a href="qt3support.html">Qt3Support</a> module.</p>
25
<li><a href="q3dictiterator-members.html">List of all members, including inherited members</a></li>
27
<a name="public-functions"></a>
28
<h3>Public Functions</h3>
30
<li><div class="fn"/><b><a href="q3dictiterator.html#Q3DictIterator">Q3DictIterator</a></b> ( const Q3Dict<type> & <i>dict</i> )</li>
31
<li><div class="fn"/><b><a href="q3dictiterator.html#dtor.Q3DictIterator">~Q3DictIterator</a></b> ()</li>
32
<li><div class="fn"/>uint <b><a href="q3dictiterator.html#count">count</a></b> () const</li>
33
<li><div class="fn"/>type * <b><a href="q3dictiterator.html#current">current</a></b> () const</li>
34
<li><div class="fn"/>QString <b><a href="q3dictiterator.html#currentKey">currentKey</a></b> () const</li>
35
<li><div class="fn"/>bool <b><a href="q3dictiterator.html#isEmpty">isEmpty</a></b> () const</li>
36
<li><div class="fn"/>type * <b><a href="q3dictiterator.html#toFirst">toFirst</a></b> ()</li>
37
<li><div class="fn"/><b><a href="q3dictiterator.html#operator-type--2a">operator type *</a></b> () const</li>
38
<li><div class="fn"/>type * <b><a href="q3dictiterator.html#operator-28-29">operator()</a></b> ()</li>
39
<li><div class="fn"/>type * <b><a href="q3dictiterator.html#operator-2b-2b">operator++</a></b> ()</li>
41
<a name="details"></a>
43
<h2>Detailed Description</h2>
44
<p>The Q3DictIterator class provides an iterator for <a href="q3dict.html">Q3Dict</a> collections.</p>
45
<p>Q3DictIterator is implemented as a template class. Define a template instance Q3DictIterator<X> to create a dictionary iterator that operates on <a href="q3dict.html">Q3Dict</a><X> (dictionary of X*).</p>
46
<p>The traversal order is arbitrary; when we speak of the "first", "last" and "next" item we are talking in terms of this arbitrary order.</p>
47
<p>Multiple iterators may independently traverse the same dictionary. A <a href="q3dict.html">Q3Dict</a> knows about all the iterators that are operating on the dictionary. When an item is removed from the dictionary, <a href="q3dict.html">Q3Dict</a> updates all iterators that are referring to the removed item to point to the next item in the (arbitrary) traversal order.</p>
49
<pre> Q3Dict<QLineEdit> fields;
50
fields.insert( "forename", new QLineEdit( this ) );
51
fields.insert( "surname", new QLineEdit( this ) );
52
fields.insert( "age", new QLineEdit( this ) );
54
fields["forename"]->setText( "Homer" );
55
fields["surname"]->setText( "Simpson" );
56
fields["age"]->setText( "45" );
58
Q3DictIterator<QLineEdit> it( fields );
59
for( ; it.current(); ++it )
60
cout << it.currentKey() << ": " << it.current()->text() << endl;
63
// Output (random order):
66
// forename: Homer</pre>
67
<p>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.</p>
68
<p>See also <a href="q3dict.html">Q3Dict</a>.</p>
70
<h2>Member Function Documentation</h2>
71
<h3 class="fn"><a name="Q3DictIterator"></a>Q3DictIterator::Q3DictIterator ( const <a href="q3dict.html">Q3Dict</a><type> & <i>dict</i> )</h3>
72
<p>Constructs an iterator for <i>dict</i>. The current iterator item is set to point to the first item in the dictionary, <i>dict</i>. First in this context means first in the arbitrary traversal order.</p>
73
<h3 class="fn"><a name="dtor.Q3DictIterator"></a>Q3DictIterator::~Q3DictIterator ()</h3>
74
<p>Destroys the iterator.</p>
75
<h3 class="fn"><a name="count"></a><a href="qtglobal.html#uint-typedef">uint</a> Q3DictIterator::count () const</h3>
76
<p>Returns the number of items in the dictionary over which the iterator is operating.</p>
77
<p>See also <a href="q3dictiterator.html#isEmpty">isEmpty</a>().</p>
78
<h3 class="fn"><a name="current"></a>type * Q3DictIterator::current () const</h3>
79
<p>Returns a pointer to the current iterator item's value.</p>
80
<h3 class="fn"><a name="currentKey"></a><a href="qstring.html">QString</a> Q3DictIterator::currentKey () const</h3>
81
<p>Returns the current iterator item's key.</p>
82
<h3 class="fn"><a name="isEmpty"></a>bool Q3DictIterator::isEmpty () const</h3>
83
<p>Returns TRUE if the dictionary is empty, i.e. <a href="q3dictiterator.html#count">count</a>() == 0; otherwise returns FALSE.</p>
84
<p>See also <a href="q3dictiterator.html#count">count</a>().</p>
85
<h3 class="fn"><a name="toFirst"></a>type * Q3DictIterator::toFirst ()</h3>
86
<p>Resets the iterator, making the first item the first current item. First in this context means first in the arbitrary traversal order. Returns a pointer to this item.</p>
87
<p>If the dictionary is empty it sets the current item to 0 and returns 0.</p>
88
<h3 class="fn"><a name="operator-type--2a"></a>Q3DictIterator::operator type * () const</h3>
89
<p>Cast operator. Returns a pointer to the current iterator item. Same as <a href="q3dictiterator.html#current">current</a>().</p>
90
<h3 class="fn"><a name="operator-28-29"></a>type * Q3DictIterator::operator() ()</h3>
91
<p>Makes the next item current and returns the original current item.</p>
92
<p>If the current iterator item was the last item in the dictionary or if it was 0, 0 is returned.</p>
93
<h3 class="fn"><a name="operator-2b-2b"></a>type * Q3DictIterator::operator++ ()</h3>
94
<p>Prefix ++ makes the next item current and returns the new current item.</p>
95
<p>If the current iterator item was the last item in the dictionary or if it was 0, 0 is returned.</p>
96
<p /><address><hr /><div align="center">
97
<table width="100%" cellspacing="0" border="0"><tr class="address">
98
<td width="30%">Copyright © 2005 <a href="trolltech.html">Trolltech</a></td>
99
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
100
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
101
</tr></table></div></address></body>