📄 qdictiterator.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/doc/qdict.doc:417 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>QDictIterator Class</title><style type="text/css"><!--h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }a:link { color: #004faf; text-decoration: none }a:visited { color: #672967; text-decoration: none }body { background: #ffffff; color: black; }--></style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr bgcolor="#E5E5E5"><td 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><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><p>The QDictIterator class provides an iterator for QDict collections.<a href="#details">More...</a><p><tt>#include <<a href="qdict-h.html">qdict.h</a>></tt><p><a href="qdictiterator-members.html">List of all member functions.</a><h2>Public Members</h2><ul><li><div class=fn><a href="#QDictIterator"><b>QDictIterator</b></a> ( const QDict<type> & dict )</div></li><li><div class=fn><a href="#~QDictIterator"><b>~QDictIterator</b></a> ()</div></li><li><div class=fn>uint <a href="#count"><b>count</b></a> () const</div></li><li><div class=fn>bool <a href="#isEmpty"><b>isEmpty</b></a> () const</div></li><li><div class=fn>type * <a href="#toFirst"><b>toFirst</b></a> ()</div></li><li><div class=fn><a href="#operator-type-*"><b>operator type *</b></a> () const</div></li><li><div class=fn>type * <a href="#current"><b>current</b></a> () const</div></li><li><div class=fn>QString <a href="#currentKey"><b>currentKey</b></a> () const</div></li><li><div class=fn>type * <a href="#operator()"><b>operator()</b></a> ()</div></li><li><div class=fn>type * <a href="#operator++"><b>operator++</b></a> ()</div></li></ul><hr><a name="details"></a><h2>Detailed Description</h2>The QDictIterator class provides an iterator for <a href="qdict.html">QDict</a> collections.<p> <p> QDictIterator is implemented as a template class.Define a template instance QDictIterator<X> to create adictionary iterator that operates on QDict<X> (dictionary of X*).<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> Multiple iterators may independently traverse the same dictionary. AQDict knows about all iterators that are operating on the dictionary.When an item is removed from the dictionary, QDict update alliterators that are referring to the removed item to point to the nextitem in the traversal order.<p> Example:<pre> <a href="qdict.html">QDict</a><QLineEdit> fields; fields.<a href="qdict.html#insert">insert</a>( "forename", new <a href="qlineedit.html">QLineEdit</a>( this ) ); fields.<a href="qdict.html#insert">insert</a>( "surname", new <a href="qlineedit.html">QLineEdit</a>( this ) ); fields.<a href="qdict.html#insert">insert</a>( "age", new <a href="qlineedit.html">QLineEdit</a>( this ) ); fields["forename"]->setText( "Homer" ); fields["surname"]->setText( "Simpson" ); fields["age"]->setText( "45" ); QDictIterator<QLineEdit> it( fields ); for( ; it.<a href="#current">current</a>(); ++it ) cout << it.<a href="#currentKey">currentKey</a>() << ": " << it.<a href="#current">current</a>()->text() << endl; cout << endl; // Output (random order): // age: 45 // surname: Simpson // forename: Homer </pre> In the example we insert some pointers to line edits into adictionary, then iterate over the dictionary printing the stringsassociated with the line edits.<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>.<hr><h2>Member Function Documentation</h2><h3 class=fn><a name="QDictIterator"></a>QDictIterator::QDictIterator ( const <a href="qdict.html">QDict</a><type> & dict )</h3>Constructs an iterator for <em>dict</em>. The current iterator item isset to point to the first item in the dictionary, <em>dict</em>. First inthis context means first in the arbitrary traversal order.<h3 class=fn><a name="~QDictIterator"></a>QDictIterator::~QDictIterator ()</h3>Destroys the iterator.<h3 class=fn>uint <a name="count"></a>QDictIterator::count () const</h3>Returns the number of items in the dictionary over which the iteratoris operating.<p>See also <a href="#isEmpty">isEmpty</a>().<h3 class=fn>type * <a name="current"></a>QDictIterator::current () const</h3>Returns a pointer to the current iterator item's value.<h3 class=fn><a href="qstring.html">QString</a> <a name="currentKey"></a>QDictIterator::currentKey () const</h3>Returns the current iterator item's key.<h3 class=fn>bool <a name="isEmpty"></a>QDictIterator::isEmpty () const</h3>Returns TRUE if the dictionary is empty, i.e. <a href="#count">count</a>() == 0; otherwisereturns FALSE.<p>See also <a href="#count">count</a>().<h3 class=fn><a name="operator-type-*"></a>QDictIterator::operator type * () const</h3>Cast operator. Returns a pointer to the current iterator item.Same as <a href="#current">current</a>().<h3 class=fn>type * <a name="operator()"></a>QDictIterator::operator() ()</h3>Makes the next item current and returns the original current item.<p> If the current iterator item was the last item in the dictionary or if itwas 0, 0 is returned.<h3 class=fn>type * <a name="operator++"></a>QDictIterator::operator++ ()</h3>Prefix ++ makes the next item current and returns the new currentitem.<p> If the current iterator item was the last item in the dictionary or if itwas 0, 0 is returned.<h3 class=fn>type * <a name="toFirst"></a>QDictIterator::toFirst ()</h3>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> If the dictionary is empty it sets the current item to 0 andreturns 0.<!-- eof --><hr><p>This file is part of the <a href="index.html">Qt toolkit</a>.Copyright © 1995-2002<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center><table width=100% cellspacing=0 border=0><tr><td>Copyright © 2002 <a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a><td align=right><div align=right>Qt version 3.0.5</div></table></div></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -