Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
doc_src_qiterator.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4//! [0]
5QList<float> list;
6...
7QListIterator<float> i(list);
8while (i.hasNext())
9 float f = i.next();
10//! [0]
11
12
13//! [1]
14QListIterator<float> i(list);
15i.toBack();
16while (i.hasPrevious())
17 float f = i.previous();
18//! [1]
19
20//! [6]
22...
23QSetIterator<QString> i(set);
24while (i.hasNext())
25 float f = i.next();
26//! [6]
27
28//! [8]
29QList<float> list;
30...
31QMutableListIterator<float> i(list);
32while (i.hasNext())
33 float f = i.next();
34//! [8]
35
36
37//! [9]
38QMutableListIterator<float> i(list);
39i.toBack();
40while (i.hasPrevious())
41 float f = i.previous();
42//! [9]
43
44
45//! [10]
46QMutableListIterator<int> i(list);
47while (i.hasNext()) {
48 int val = i.next();
49 if (val < 0) {
50 i.setValue(-val);
51 } else if (val == 0) {
52 i.remove();
53 }
54}
55//! [10]
56
57//! [17]
58QSet<float> set;
59...
60QMutableSetIterator<float> i(set);
61while (i.hasNext())
62 float f = i.next();
63//! [17]
64
65//! [19]
66QMutableListIterator<int> i(list);
67while (i.hasNext()) {
68 int val = i.next();
69 if (val < -32768 || val > 32767)
70 i.remove();
71}
72//! [19]
73
74//! [22]
75QMutableSetIterator<int> i(set);
76while (i.hasNext()) {
77 int val = i.next();
78 if (val < -32768 || val > 32767)
79 i.remove();
80}
81//! [22]
82
83
84//! [23]
85QMutableListIterator<double> i(list);
86while (i.hasNext()) {
87 double val = i.next();
88 i.setValue(std::sqrt(val));
89}
90//! [23]
91
92//! [26]
94...
95QMapIterator<int, QWidget *> i(map);
96while (i.hasNext()) {
97 i.next();
98 qDebug() << i.key() << ": " << i.value();
99}
100//! [26]
101
102
103//! [27]
104QMapIterator<int, QWidget *> i(map);
105i.toBack();
106while (i.hasPrevious()) {
107 i.previous();
108 qDebug() << i.key() << ": " << i.value();
109}
110//! [27]
111
112
113//! [28]
114QMapIterator<int, QWidget *> i(map);
115while (i.findNext(widget)) {
116 qDebug() << "Found widget " << widget << " under key "
117 << i.key();
118}
119//! [28]
120
121//! [26multi]
123...
124QMultiMapIterator<int, QWidget *> i(multimap);
125while (i.hasNext()) {
126 i.next();
127 qDebug() << i.key() << ": " << i.value();
128}
129//! [26multi]
130
131
132//! [27multi]
133QMultiMapIterator<int, QWidget *> i(multimap);
134i.toBack();
135while (i.hasPrevious()) {
136 i.previous();
137 qDebug() << i.key() << ": " << i.value();
138}
139//! [27multi]
140
141
142//! [28multi]
143QMultiMapIterator<int, QWidget *> i(multimap);
144while (i.findNext(widget)) {
145 qDebug() << "Found widget " << widget << " under key "
146 << i.key();
147}
148//! [28multi]
149
150
151//! [29]
153...
154QHashIterator<int, QWidget *> i(hash);
155while (i.hasNext()) {
156 i.next();
157 qDebug() << i.key() << ": " << i.value();
158}
159//! [29]
160
161
162//! [31]
163QHashIterator<int, QWidget *> i(hash);
164while (i.findNext(widget)) {
165 qDebug() << "Found widget " << widget << " under key "
166 << i.key();
167}
168//! [31]
169
170
171//! [32]
172QMap<int, QWidget *> map;
173...
174QMutableMapIterator<int, QWidget *> i(map);
175while (i.hasNext()) {
176 i.next();
177 qDebug() << i.key() << ": " << i.value();
178}
179//! [32]
180
181
182//! [33]
183QMutableMapIterator<int, QWidget *> i(map);
184i.toBack();
185while (i.hasPrevious()) {
186 i.previous();
187 qDebug() << i.key() << ": " << i.value();
188}
189//! [33]
190
191
192//! [34]
193QMutableMapIterator<int, QWidget *> i(map);
194while (i.findNext(widget)) {
195 qDebug() << "Found widget " << widget << " under key "
196 << i.key();
197}
198//! [34]
199
200
201//! [35]
203while (i.hasNext()) {
204 i.next();
205 if (i.key() == i.value())
206 i.remove();
207}
208//! [35]
209
210
211//! [32multi]
213...
214QMutableMultiMapIterator<int, QWidget *> i(multimap);
215while (i.hasNext()) {
216 i.next();
217 qDebug() << i.key() << ": " << i.value();
218}
219//! [32multi]
220
221
222//! [33multi]
223QMutableMultiMapIterator<int, QWidget *> i(multimap);
224i.toBack();
225while (i.hasPrevious()) {
226 i.previous();
227 qDebug() << i.key() << ": " << i.value();
228}
229//! [33multi]
230
231
232//! [34multi]
233QMutableMultiMapIterator<int, QWidget *> i(multimap);
234while (i.findNext(widget)) {
235 qDebug() << "Found widget " << widget << " under key "
236 << i.key();
237}
238//! [34multi]
239
240
241//! [35multi]
243while (i.hasNext()) {
244 i.next();
245 if (i.key() == i.value())
246 i.remove();
247}
248//! [35multi]
249
250
251//! [36]
252QHash<int, QWidget *> hash;
253...
254QMutableHashIterator<QString, QWidget *> i(hash);
255while (i.hasNext()) {
256 i.next();
257 qDebug() << i.key() << ": " << i.value();
258}
259//! [36]
260
261
262//! [38]
263QMutableHashIterator<int, QWidget *> i(hash);
264while (i.findNext(widget)) {
265 qDebug() << "Found widget " << widget << " under key "
266 << i.key();
267}
268//! [38]
269
270
271//! [39]
273while (i.hasNext()) {
274 i.next();
275 if (i.key() == i.value())
276 i.remove();
277}
278//! [39]
QMap< QString, QString > map
[6]
QHash< int, QWidget * > hash
[35multi]
QMultiMap< int, QWidget * > multimap
[28]
auto i
QList< int > list
[14]
QFuture< QSet< QChar > > set
[10]