[190] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
| 2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/qdict.doc:410 -->
|
---|
| 3 | <html>
|
---|
| 4 | <head>
|
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
| 6 | <title>QDictIterator Class</title>
|
---|
| 7 | <style type="text/css"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { background: #ffffff; color: black; }
|
---|
| 12 | --></style>
|
---|
| 13 | </head>
|
---|
| 14 | <body>
|
---|
| 15 |
|
---|
| 16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
| 17 | <tr bgcolor="#E5E5E5">
|
---|
| 18 | <td valign=center>
|
---|
| 19 | <a href="index.html">
|
---|
| 20 | <font color="#004faf">Home</font></a>
|
---|
| 21 | | <a href="classes.html">
|
---|
| 22 | <font color="#004faf">All Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main Classes</font></a>
|
---|
| 25 | | <a href="annotated.html">
|
---|
| 26 | <font color="#004faf">Annotated</font></a>
|
---|
| 27 | | <a href="groups.html">
|
---|
| 28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
| 29 | | <a href="functions.html">
|
---|
| 30 | <font color="#004faf">Functions</font></a>
|
---|
| 31 | </td>
|
---|
| 32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QDictIterator Class Reference</h1>
|
---|
| 33 |
|
---|
| 34 | <p>The QDictIterator class provides an iterator for QDict collections.
|
---|
| 35 | <a href="#details">More...</a>
|
---|
| 36 | <p><tt>#include <<a href="qdict-h.html">qdict.h</a>></tt>
|
---|
| 37 | <p><a href="qdictiterator-members.html">List of all member functions.</a>
|
---|
| 38 | <h2>Public Members</h2>
|
---|
| 39 | <ul>
|
---|
| 40 | <li class=fn><a href="#QDictIterator"><b>QDictIterator</b></a> ( const QDict<type> & dict )</li>
|
---|
| 41 | <li class=fn><a href="#~QDictIterator"><b>~QDictIterator</b></a> ()</li>
|
---|
| 42 | <li class=fn>uint <a href="#count"><b>count</b></a> () const</li>
|
---|
| 43 | <li class=fn>bool <a href="#isEmpty"><b>isEmpty</b></a> () const</li>
|
---|
| 44 | <li class=fn>type * <a href="#toFirst"><b>toFirst</b></a> ()</li>
|
---|
| 45 | <li class=fn><a href="#operator-type-*"><b>operator type *</b></a> () const</li>
|
---|
| 46 | <li class=fn>type * <a href="#current"><b>current</b></a> () const</li>
|
---|
| 47 | <li class=fn>QString <a href="#currentKey"><b>currentKey</b></a> () const</li>
|
---|
| 48 | <li class=fn>type * <a href="#operator()"><b>operator()</b></a> ()</li>
|
---|
| 49 | <li class=fn>type * <a href="#operator++"><b>operator++</b></a> ()</li>
|
---|
| 50 | </ul>
|
---|
| 51 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
| 52 |
|
---|
| 53 |
|
---|
| 54 | The QDictIterator class provides an iterator for <a href="qdict.html">QDict</a> collections.
|
---|
| 55 | <p>
|
---|
| 56 |
|
---|
| 57 | <p> QDictIterator is implemented as a template class. Define a
|
---|
| 58 | template instance QDictIterator<X> to create a dictionary
|
---|
| 59 | iterator that operates on QDict<X> (dictionary of X*).
|
---|
| 60 | <p> The traversal order is arbitrary; when we speak of the "first",
|
---|
| 61 | "last" and "next" item we are talking in terms of this arbitrary
|
---|
| 62 | order.
|
---|
| 63 | <p> Multiple iterators may independently traverse the same dictionary.
|
---|
| 64 | A QDict knows about all the iterators that are operating on the
|
---|
| 65 | dictionary. When an item is removed from the dictionary, QDict
|
---|
| 66 | updates all iterators that are referring to the removed item to
|
---|
| 67 | point to the next item in the (arbitrary) traversal order.
|
---|
| 68 | <p> Example:
|
---|
| 69 | <pre>
|
---|
| 70 | <a href="qdict.html">QDict</a><QLineEdit> fields;
|
---|
| 71 | fields.<a href="qdict.html#insert">insert</a>( "forename", new <a href="qlineedit.html">QLineEdit</a>( this ) );
|
---|
| 72 | fields.<a href="qdict.html#insert">insert</a>( "surname", new <a href="qlineedit.html">QLineEdit</a>( this ) );
|
---|
| 73 | fields.<a href="qdict.html#insert">insert</a>( "age", new <a href="qlineedit.html">QLineEdit</a>( this ) );
|
---|
| 74 |
|
---|
| 75 | fields["forename"]->setText( "Homer" );
|
---|
| 76 | fields["surname"]->setText( "Simpson" );
|
---|
| 77 | fields["age"]->setText( "45" );
|
---|
| 78 |
|
---|
| 79 | QDictIterator<QLineEdit> it( fields );
|
---|
| 80 | for( ; it.<a href="#current">current</a>(); ++it )
|
---|
| 81 | cout << it.<a href="#currentKey">currentKey</a>() << ": " << it.<a href="#current">current</a>()->text() << endl;
|
---|
| 82 | cout << endl;
|
---|
| 83 |
|
---|
| 84 | // Output (random order):
|
---|
| 85 | // age: 45
|
---|
| 86 | // surname: Simpson
|
---|
| 87 | // forename: Homer
|
---|
| 88 | </pre>
|
---|
| 89 |
|
---|
| 90 | In the example we insert some pointers to line edits into a
|
---|
| 91 | dictionary, then iterate over the dictionary printing the strings
|
---|
| 92 | associated with the line edits.
|
---|
| 93 | <p> <p>See also <a href="qdict.html">QDict</a>, <a href="collection.html">Collection Classes</a>, and <a href="tools.html">Non-GUI Classes</a>.
|
---|
| 94 |
|
---|
| 95 | <hr><h2>Member Function Documentation</h2>
|
---|
| 96 | <h3 class=fn><a name="QDictIterator"></a>QDictIterator::QDictIterator ( const <a href="qdict.html">QDict</a><type> & dict )
|
---|
| 97 | </h3>
|
---|
| 98 |
|
---|
| 99 | <p> Constructs an iterator for <em>dict</em>. The current iterator item is
|
---|
| 100 | set to point to the first item in the dictionary, <em>dict</em>. First
|
---|
| 101 | in this context means first in the arbitrary traversal order.
|
---|
| 102 |
|
---|
| 103 | <h3 class=fn><a name="~QDictIterator"></a>QDictIterator::~QDictIterator ()
|
---|
| 104 | </h3>
|
---|
| 105 |
|
---|
| 106 | <p> Destroys the iterator.
|
---|
| 107 |
|
---|
| 108 | <h3 class=fn>uint <a name="count"></a>QDictIterator::count () const
|
---|
| 109 | </h3>
|
---|
| 110 |
|
---|
| 111 | <p> Returns the number of items in the dictionary over which the
|
---|
| 112 | iterator is operating.
|
---|
| 113 | <p> <p>See also <a href="#isEmpty">isEmpty</a>().
|
---|
| 114 |
|
---|
| 115 | <h3 class=fn>type * <a name="current"></a>QDictIterator::current () const
|
---|
| 116 | </h3>
|
---|
| 117 |
|
---|
| 118 | <p> Returns a pointer to the current iterator item's value.
|
---|
| 119 |
|
---|
| 120 | <h3 class=fn><a href="qstring.html">QString</a> <a name="currentKey"></a>QDictIterator::currentKey () const
|
---|
| 121 | </h3>
|
---|
| 122 |
|
---|
| 123 | <p> Returns the current iterator item's key.
|
---|
| 124 |
|
---|
| 125 | <h3 class=fn>bool <a name="isEmpty"></a>QDictIterator::isEmpty () const
|
---|
| 126 | </h3>
|
---|
| 127 |
|
---|
| 128 | <p> Returns TRUE if the dictionary is empty, i.e. <a href="#count">count</a>() == 0;
|
---|
| 129 | otherwise returns FALSE.
|
---|
| 130 | <p> <p>See also <a href="#count">count</a>().
|
---|
| 131 |
|
---|
| 132 | <h3 class=fn><a name="operator-type-*"></a>QDictIterator::operator type * () const
|
---|
| 133 | </h3>
|
---|
| 134 |
|
---|
| 135 | <p> Cast operator. Returns a pointer to the current iterator item.
|
---|
| 136 | Same as <a href="#current">current</a>().
|
---|
| 137 |
|
---|
| 138 | <h3 class=fn>type * <a name="operator()"></a>QDictIterator::operator() ()
|
---|
| 139 | </h3>
|
---|
| 140 |
|
---|
| 141 | <p> Makes the next item current and returns the original current item.
|
---|
| 142 | <p> If the current iterator item was the last item in the dictionary
|
---|
| 143 | or if it was 0, 0 is returned.
|
---|
| 144 |
|
---|
| 145 | <h3 class=fn>type * <a name="operator++"></a>QDictIterator::operator++ ()
|
---|
| 146 | </h3>
|
---|
| 147 |
|
---|
| 148 | <p> Prefix ++ makes the next item current and returns the new current
|
---|
| 149 | item.
|
---|
| 150 | <p> If the current iterator item was the last item in the dictionary
|
---|
| 151 | or if it was 0, 0 is returned.
|
---|
| 152 |
|
---|
| 153 | <h3 class=fn>type * <a name="toFirst"></a>QDictIterator::toFirst ()
|
---|
| 154 | </h3>
|
---|
| 155 |
|
---|
| 156 | <p> Resets the iterator, making the first item the first current item.
|
---|
| 157 | First in this context means first in the arbitrary traversal
|
---|
| 158 | order. Returns a pointer to this item.
|
---|
| 159 | <p> If the dictionary is empty it sets the current item to 0 and
|
---|
| 160 | returns 0.
|
---|
| 161 |
|
---|
| 162 | <!-- eof -->
|
---|
| 163 | <hr><p>
|
---|
| 164 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
| 165 | Copyright © 1995-2007
|
---|
| 166 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
| 167 | <table width=100% cellspacing=0 border=0><tr>
|
---|
| 168 | <td>Copyright © 2007
|
---|
| 169 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
| 170 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
| 171 | </table></div></address></body>
|
---|
| 172 | </html>
|
---|