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/qptrdict.doc:319 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>QPtrDictIterator 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>QPtrDictIterator Class Reference</h1>
|
---|
33 |
|
---|
34 | <p>The QPtrDictIterator class provides an iterator for QPtrDict collections.
|
---|
35 | <a href="#details">More...</a>
|
---|
36 | <p><tt>#include <<a href="qptrdict-h.html">qptrdict.h</a>></tt>
|
---|
37 | <p><a href="qptrdictiterator-members.html">List of all member functions.</a>
|
---|
38 | <h2>Public Members</h2>
|
---|
39 | <ul>
|
---|
40 | <li class=fn><a href="#QPtrDictIterator"><b>QPtrDictIterator</b></a> ( const QPtrDict<type> & dict )</li>
|
---|
41 | <li class=fn><a href="#~QPtrDictIterator"><b>~QPtrDictIterator</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>void * <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 | <li class=fn>type * <a href="#operator+-eq"><b>operator+=</b></a> ( uint jump )</li>
|
---|
51 | </ul>
|
---|
52 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
53 |
|
---|
54 |
|
---|
55 | The QPtrDictIterator class provides an iterator for <a href="qptrdict.html">QPtrDict</a> collections.
|
---|
56 | <p>
|
---|
57 |
|
---|
58 | <p> QPtrDictIterator is implemented as a template class. Define a
|
---|
59 | template instance QPtrDictIterator<X> to create a dictionary
|
---|
60 | iterator that operates on QPtrDict<X> (dictionary of X*).
|
---|
61 | <p> Example:
|
---|
62 | <pre>
|
---|
63 | <a href="qptrdict.html">QPtrDict</a><char> fields;
|
---|
64 |
|
---|
65 | <a href="qlineedit.html">QLineEdit</a> *le1 = new <a href="qlineedit.html">QLineEdit</a>( this );
|
---|
66 | le1-><a href="qlineedit.html#setText">setText</a>( "Simpson" );
|
---|
67 | <a href="qlineedit.html">QLineEdit</a> *le2 = new <a href="qlineedit.html">QLineEdit</a>( this );
|
---|
68 | le2-><a href="qlineedit.html#setText">setText</a>( "Homer" );
|
---|
69 | <a href="qlineedit.html">QLineEdit</a> *le3 = new <a href="qlineedit.html">QLineEdit</a>( this );
|
---|
70 | le3-><a href="qlineedit.html#setText">setText</a>( "45" );
|
---|
71 |
|
---|
72 | fields.<a href="qptrdict.html#insert">insert</a>( le1, "Surname" );
|
---|
73 | fields.<a href="qptrdict.html#insert">insert</a>( le2, "Forename" );
|
---|
74 | fields.<a href="qptrdict.html#insert">insert</a>( le3, "Age" );
|
---|
75 |
|
---|
76 | QPtrDictIterator<char> it( fields );
|
---|
77 | for( ; it.<a href="#current">current</a>(); ++it ) {
|
---|
78 | <a href="qlineedit.html">QLineEdit</a> *le = (QLineEdit)it.<a href="#currentKey">currentKey</a>();
|
---|
79 | cout << it.<a href="#current">current</a>() << ": " << le-><a href="qlineedit.html#text">text</a>() << endl;
|
---|
80 | }
|
---|
81 | cout << endl;
|
---|
82 |
|
---|
83 | // Output (random order):
|
---|
84 | // Forename: Homer
|
---|
85 | // Age: 45
|
---|
86 | // Surname: Simpson
|
---|
87 | </pre>
|
---|
88 |
|
---|
89 | In the example we insert some line edits into a dictionary,
|
---|
90 | associating a string with each. We then iterate over the
|
---|
91 | dictionary printing the associated strings.
|
---|
92 | <p> Multiple iterators may independently traverse the same dictionary.
|
---|
93 | A <a href="qptrdict.html">QPtrDict</a> knows about all the iterators that are operating on the
|
---|
94 | dictionary. When an item is removed from the dictionary, QPtrDict
|
---|
95 | updates all iterators that refer the removed item to point to the
|
---|
96 | next item in the traversing order.
|
---|
97 | <p> <p>See also <a href="qptrdict.html">QPtrDict</a>, <a href="collection.html">Collection Classes</a>, and <a href="tools.html">Non-GUI Classes</a>.
|
---|
98 |
|
---|
99 | <hr><h2>Member Function Documentation</h2>
|
---|
100 | <h3 class=fn><a name="QPtrDictIterator"></a>QPtrDictIterator::QPtrDictIterator ( const <a href="qptrdict.html">QPtrDict</a><type> & dict )
|
---|
101 | </h3>
|
---|
102 |
|
---|
103 | <p> Constructs an iterator for <em>dict</em>. The current iterator item is
|
---|
104 | set to point on the first item in the <em>dict</em>.
|
---|
105 |
|
---|
106 | <h3 class=fn><a name="~QPtrDictIterator"></a>QPtrDictIterator::~QPtrDictIterator ()
|
---|
107 | </h3>
|
---|
108 |
|
---|
109 | <p> Destroys the iterator.
|
---|
110 |
|
---|
111 | <h3 class=fn>uint <a name="count"></a>QPtrDictIterator::count () const
|
---|
112 | </h3>
|
---|
113 |
|
---|
114 | <p> Returns the number of items in the dictionary this iterator
|
---|
115 | operates on.
|
---|
116 | <p> <p>See also <a href="#isEmpty">isEmpty</a>().
|
---|
117 |
|
---|
118 | <h3 class=fn>type * <a name="current"></a>QPtrDictIterator::current () const
|
---|
119 | </h3>
|
---|
120 |
|
---|
121 | <p> Returns a pointer to the current iterator item's value.
|
---|
122 |
|
---|
123 | <h3 class=fn>void * <a name="currentKey"></a>QPtrDictIterator::currentKey () const
|
---|
124 | </h3>
|
---|
125 |
|
---|
126 | <p> Returns the current iterator item's key.
|
---|
127 |
|
---|
128 | <h3 class=fn>bool <a name="isEmpty"></a>QPtrDictIterator::isEmpty () const
|
---|
129 | </h3>
|
---|
130 |
|
---|
131 | <p> Returns TRUE if the dictionary is empty; otherwise returns FALSE.
|
---|
132 | <p> <p>See also <a href="#count">count</a>().
|
---|
133 |
|
---|
134 | <h3 class=fn><a name="operator-type-*"></a>QPtrDictIterator::operator type * () const
|
---|
135 | </h3>
|
---|
136 |
|
---|
137 | <p> Cast operator. Returns a pointer to the current iterator item.
|
---|
138 | Same as <a href="#current">current</a>().
|
---|
139 |
|
---|
140 | <h3 class=fn>type * <a name="operator()"></a>QPtrDictIterator::operator() ()
|
---|
141 | </h3>
|
---|
142 |
|
---|
143 | <p> Makes the succeeding item current and returns the original current
|
---|
144 | item.
|
---|
145 | <p> If the current iterator item was the last item in the dictionary
|
---|
146 | or if it was 0, 0 is returned.
|
---|
147 |
|
---|
148 | <h3 class=fn>type * <a name="operator++"></a>QPtrDictIterator::operator++ ()
|
---|
149 | </h3>
|
---|
150 |
|
---|
151 | <p> Prefix ++ makes the succeeding item current and returns the new
|
---|
152 | current item.
|
---|
153 | <p> If the current iterator item was the last item in the dictionary
|
---|
154 | or if it was 0, 0 is returned.
|
---|
155 |
|
---|
156 | <h3 class=fn>type * <a name="operator+-eq"></a>QPtrDictIterator::operator+= ( uint jump )
|
---|
157 | </h3>
|
---|
158 |
|
---|
159 | <p> Sets the current item to the item <em>jump</em> positions after the
|
---|
160 | current item and returns a pointer to that item.
|
---|
161 | <p> If that item is beyond the last item or if the dictionary is
|
---|
162 | empty, it sets the current item to 0 and returns 0.
|
---|
163 |
|
---|
164 | <h3 class=fn>type * <a name="toFirst"></a>QPtrDictIterator::toFirst ()
|
---|
165 | </h3>
|
---|
166 |
|
---|
167 | <p> Sets the current iterator item to point to the first item in the
|
---|
168 | dictionary and returns a pointer to the item. If the dictionary is
|
---|
169 | empty, it sets the current item to 0 and returns 0.
|
---|
170 |
|
---|
171 | <!-- eof -->
|
---|
172 | <hr><p>
|
---|
173 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
174 | Copyright © 1995-2007
|
---|
175 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
176 | <table width=100% cellspacing=0 border=0><tr>
|
---|
177 | <td>Copyright © 2007
|
---|
178 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
179 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
180 | </table></div></address></body>
|
---|
181 | </html>
|
---|