Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
doc_src_qset.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
5QSet<QString> set;
7
8
10set.insert("one");
11set.insert("three");
12set.insert("seven");
14
15
17set << "twelve" << "fifteen" << "nineteen";
19
20
22if (!set.contains("ninety-nine"))
23 ...
25
26
28QSetIterator<QWidget *> i(set);
29while (i.hasNext()) {
30 QWidget *w = i.next();
31 qDebug() << w;
32}
34
35
37for (auto i = set.cbegin(), end = set.cend(); i != end; ++i)
38 qDebug() << *i;
40
41
43QSet<QString> set;
44...
45for (const auto &value : set)
46 qDebug() << value;
48
49
51QSet<QString> set;
52set.reserve(20000);
53for (int i = 0; i < 20000; ++i)
56
57
59QSet<QString> set = {"January", "February", ... "December"}
60
61// i is a QSet<QString>::iterator
62for (auto i = set.begin(), end = set.end(); i != end; ++i)
63 qDebug() << *i;
65
66
68QSet<QString> set = {"January", "February", ... "December"};
69
70auto i = set.begin();
71while (i != set.end()) {
72 if ((*i).startsWith('J')) {
73 i = set.erase(i);
74 } else {
75 ++i;
76 }
77}
79
80
82QSet<QString> set;
83...
84const auto predicate = [](const QString &s) { return s.compare("Jeanette", Qt::CaseInsensitive) == 0; };
86if (it != set.end())
87 cout << "Found Jeanette" << endl;
89
90
92QSet<QString> set = {"January", "February", ... "December"};
93
94// i is QSet<QString>::const_iterator
95for (auto i = set.cbegin(), end = set.cend(); i != end; ++i)
96 qDebug() << *i;
98
99
101QSet<QString> set;
102...
103const auto predicate = [](const QString &s) { return s.compare("Jeanette", Qt::CaseInsensitive) == 0; };
105if (it != set.constEnd())
106 cout << "Found Jeanette" << endl;
iterator begin()
Definition qset.h:136
iterator end()
Definition qset.h:140
const_iterator cend() const noexcept
Definition qset.h:142
const_iterator constEnd() const noexcept
Definition qset.h:143
iterator erase(const_iterator i)
Definition qset.h:145
void reserve(qsizetype size)
Definition qset.h:226
bool contains(const T &value) const
Definition qset.h:71
const_iterator cbegin() const noexcept
Definition qset.h:138
iterator insert(const T &value)
Definition qset.h:155
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
const auto predicate
QSet< QString >::iterator it
auto i
QSet< QString > set
[0]
@ CaseInsensitive
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define qDebug
[1]
Definition qlogging.h:164
GLenum GLsizei GLsizei GLint * values
[15]
GLfloat GLfloat GLfloat w
[0]
GLuint GLuint end
GLdouble s
[6]
Definition qopenglext.h:235