File: qlistviewitemiterator.html

package info (click to toggle)
qt-x11 3%3A2.3.1-22
  • links: PTS
  • area: main
  • in suites: woody
  • size: 48,524 kB
  • ctags: 46,337
  • sloc: cpp: 260,077; ansic: 32,457; makefile: 31,131; yacc: 2,444; sh: 1,513; lex: 480; perl: 422; xml: 68; lisp: 15
file content (161 lines) | stat: -rw-r--r-- 10,111 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QListViewItemIterator 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: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">

<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>

<h1 align=center>QListViewItemIterator Class Reference</h1><br clear="all">
<p>
The QListViewItemIterator class provides an iterator for collections of QListViewItems
<a href="#details">More...</a>
<p>
<code>#include &lt;<a href="qlistview-h.html">qlistview.h</a>&gt;</code>
<p><a href="qlistviewitemiterator-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn"><a href="#40cb04"><b>QListViewItemIterator</b></a>()</div>
<li><div class="fn"><a href="#55c631"><b>QListViewItemIterator</b></a>(QListViewItem*item)</div>
<li><div class="fn"><a href="#f9df0b"><b>QListViewItemIterator</b></a>(constQListViewItemIterator&amp;it)</div>
<li><div class="fn"><a href="#295bd6"><b>QListViewItemIterator</b></a>(QListView*lv)</div>
<li><div class="fn">QListViewItemIterator&amp;<a href="#ed8fbb"><b>operator=</b></a>(constQListViewItemIterator&amp;it)</div>
<li><div class="fn"><a href="#74ea94"><b>~QListViewItemIterator</b></a>()</div>
<li><div class="fn">QListViewItemIterator&amp;<a href="#0a030e"><b>operator++</b></a>()</div>
<li><div class="fn">constQListViewItemIterator<a href="#7dbf4d"><b>operator++</b></a>(int)</div>
<li><div class="fn">QListViewItemIterator&amp;<a href="#0a795f"><b>operator+=</b></a>(intj)</div>
<li><div class="fn">QListViewItemIterator&amp;<a href="#271136"><b>operator--</b></a>()</div>
<li><div class="fn">constQListViewItemIterator<a href="#e52709"><b>operator--</b></a>(int)</div>
<li><div class="fn">QListViewItemIterator&amp;<a href="#f7dc3c"><b>operator-=</b></a>(intj)</div>
<li><div class="fn">QListViewItem*<a href="#42e4b3"><b>current</b></a>()const</div>
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QListViewItemIterator class provides an iterator for collections of QListViewItems
<p>
Construct an instance of a QListViewItemIterator with either a
<a href="qlistview.html">QListView</a>* or a <a href="qlistviewitem.html">QListViewItem</a>* as argument, to operate on the tree
of QListViewItems.
<p>A QListViewItemIterator iterates over all items of a listview. This means ++it makes always
the first child of the current item the new current one. If there is no child, the next sibling
gets the new current item, and if there is no next sibling, the next sibling of the parent is
set to current.
<p>Example:
<p>Often you want to get all items, which were selected by a user. Here is
an example which does this and stores the pointers to all selected items
in a <a href="qlist.html">QList</a>.
<p><pre>  // Somewhere a listview is generated like this
  <a href="qlistview.html">QListView</a> *lv = new <a href="qlistview.html">QListView</a>(this);
  // Enable multiselection
  lv-&gt;<a href="qlistview.html#562710">setMultiSelection</a>( TRUE );

  // Insert the items here

  // ...

  // This function is called to get a list of the selected items of a listview
  <a href="qlist.html">QList</a>&lt;<a href="qlistviewitem.html">QListViewItem</a>&gt; * getSelectedItems( <a href="qlistview.html">QListView</a> *lv ) {
    if ( !lv )
      return 0;

    // Create the list
    <a href="qlist.html">QList</a>&lt;<a href="qlistviewitem.html">QListViewItem</a>&gt; *lst = new <a href="qlist.html">QList</a>&lt;<a href="qlistviewitem.html">QListViewItem</a>&gt;;
    lst-&gt;<a href="qcollection.html#a3fc3c">setAutoDelete</a>( FALSE );

    // Create an iterator and give the listview as argument
    <a href="qlistviewitemiterator.html">QListViewItemIterator</a> it( lv );
    // iterate through all items of the listview
    for ( ; it.<a href="#42e4b3">current</a>(); ++it ) {
      if ( it.<a href="#42e4b3">current</a>()-&gt;isSelected() )
        lst-&gt;<a href="qlist.html#687e74">append</a>( it.<a href="#42e4b3">current</a>() );
    }

    return lst;
  }
</pre>
<p>Using a QListViewItemIterator is a convenient way to traverse the
tree of QListViewItems of a QListView. It makes especially operating
on a hierarchical QListView easy.
<p>Also, multiple QListViewItemIterators can operate on the tree of
QListViewItems.  A QListView knows about all iterators which are
operating on its QListViewItems.  So when a QListViewItem gets
removed, all iterators that point to this item get updated and point
to the new current item after that.
<p>See also  <a href="qlistview.html">QListView</a> and <a href="qlistviewitem.html">QListViewItem</a>.

<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="40cb04"></a>QListViewItemIterator::QListViewItemIterator()</h3>
<p>Constructs an empty iterator.
<h3 class="fn"><a name="295bd6"></a>QListViewItemIterator::QListViewItemIterator(<a href="qlistview.html">QListView</a>*lv)</h3>
<p>Constructs an iterator for the <a href="qlistview.html">QListView</a> <em>lv.</em> The current
iterator item is set to point on the first child ( <a href="qlistviewitem.html">QListViewItem</a> )
of <em>lv.</em>
<h3 class="fn"><a name="55c631"></a>QListViewItemIterator::QListViewItemIterator(<a href="qlistviewitem.html">QListViewItem</a>*item)</h3>
<p>Constructs an iterator for the <a href="qlistview.html">QListView</a> of the <em>item.</em> The
current iterator item is set to point on the <em>item.</em>
<h3 class="fn"><a name="f9df0b"></a>QListViewItemIterator::QListViewItemIterator(constQListViewItemIterator&amp;it)</h3>
<p>Constructs an iterator for the same <a href="qlistview.html">QListView</a> as <em>it.</em> The
current iterator item is set to point on the current item of <em>it.</em>
<h3 class="fn"><a name="74ea94"></a>QListViewItemIterator::~QListViewItemIterator()</h3>
<p>Destroys the iterator.
<h3 class="fn"><a href="qlistviewitem.html">QListViewItem</a>*<a name="42e4b3"></a>QListViewItemIterator::current()const</h3>
<p>Returns a pointer to the current item of the iterator.
<h3 class="fn">QListViewItemIterator&amp;<a name="0a030e"></a>QListViewItemIterator::operator++()</h3>
<p>Prefix ++ makes the next item in the <a href="qlistviewitem.html">QListViewItem</a> tree of the
<a href="qlistview.html">QListView</a> of the iterator the current item and returns it. If the
current item was the last item in the QListView or null, null is
returned.
<h3 class="fn">constQListViewItemIterator<a name="7dbf4d"></a>QListViewItemIterator::operator++(int)</h3>
<p>Postfix ++ makes the next item in the <a href="qlistviewitem.html">QListViewItem</a> tree of the
<a href="qlistview.html">QListView</a> of the iterator the current item and returns the item,
which was the current one before.
<h3 class="fn">QListViewItemIterator&amp;<a name="0a795f"></a>QListViewItemIterator::operator+=(intj)</h3>
<p>Sets the current item to the item <em>j</em> positions after the current
item in the <a href="qlistviewitem.html">QListViewItem</a> hierarchy. If this item is beyond the last
item, the current item is set to null.
<p>The new current item (or null, if the new current item is null) is returned.
<h3 class="fn">QListViewItemIterator&amp;<a name="271136"></a>QListViewItemIterator::operator--()</h3>
<p>Prefix -- makes the previous item in the <a href="qlistviewitem.html">QListViewItem</a> tree of the
<a href="qlistview.html">QListView</a> of the iterator the current item and returns it. If the
current item was the last first in the QListView or null, null is
returned.
<h3 class="fn">constQListViewItemIterator<a name="e52709"></a>QListViewItemIterator::operator--(int)</h3>
<p>Postfix -- makes the previous item in the <a href="qlistviewitem.html">QListViewItem</a> tree of
the <a href="qlistview.html">QListView</a> of the iterator the current item and returns the item,
which was the current one before.
<h3 class="fn">QListViewItemIterator&amp;<a name="f7dc3c"></a>QListViewItemIterator::operator-=(intj)</h3>
<p>Sets the current item to the item <em>j</em> positions before the
current item in the <a href="qlistviewitem.html">QListViewItem</a> hierarchy. If this item is above
the first item, the current item is set to null.  The new current
item (or null, if the new current item is null) is returned.
<h3 class="fn">QListViewItemIterator&amp;<a name="ed8fbb"></a>QListViewItemIterator::operator=(constQListViewItemIterator&amp;it)</h3>
<p>Assignment. Makes a copy of <em>it</em> and returns a reference to its
iterator.
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.1"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright &copy; 1995-2000
<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  2000 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.1</div>
</table></div></address></body></html>