summaryrefslogtreecommitdiffstats
path: root/src/corelib/doc/snippets/code
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/doc/snippets/code')
-rw-r--r--src/corelib/doc/snippets/code/doc_src_properties.cpp2
-rw-r--r--src/corelib/doc/snippets/code/doc_src_qalgorithms.cpp10
-rw-r--r--src/corelib/doc/snippets/code/doc_src_qiterator.cpp16
-rw-r--r--src/corelib/doc/snippets/code/qlogging/qlogging.cpp4
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp8
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qstringiterator.cpp72
6 files changed, 94 insertions, 18 deletions
diff --git a/src/corelib/doc/snippets/code/doc_src_properties.cpp b/src/corelib/doc/snippets/code/doc_src_properties.cpp
index 7a70200cce..f76fef6ebd 100644
--- a/src/corelib/doc/snippets/code/doc_src_properties.cpp
+++ b/src/corelib/doc/snippets/code/doc_src_properties.cpp
@@ -48,7 +48,7 @@ Q_PROPERTY(type name
[DESIGNABLE bool]
[SCRIPTABLE bool]
[STORED bool]
- [USER bool]
+ [USER bool]
[CONSTANT]
[FINAL])
//! [0]
diff --git a/src/corelib/doc/snippets/code/doc_src_qalgorithms.cpp b/src/corelib/doc/snippets/code/doc_src_qalgorithms.cpp
index 4ff7e87b16..54d9f01cc4 100644
--- a/src/corelib/doc/snippets/code/doc_src_qalgorithms.cpp
+++ b/src/corelib/doc/snippets/code/doc_src_qalgorithms.cpp
@@ -274,9 +274,9 @@ list.insert(i, 12);
QVector<int> vect;
vect << 3 << 3 << 6 << 6 << 6 << 8;
QVector<int>::iterator begin6 =
- qLowerBound(vect.begin(), vect.end(), 6);
+ qLowerBound(vect.begin(), vect.end(), 6);
QVector<int>::iterator end6 =
- qUpperBound(begin6, vect.end(), 6);
+ qUpperBound(begin6, vect.end(), 6);
QVector<int>::iterator i = begin6;
while (i != end6) {
@@ -305,9 +305,9 @@ list.insert(i, 12);
QVector<int> vect;
vect << 3 << 3 << 6 << 6 << 6 << 8;
QVector<int>::iterator begin6 =
- qLowerBound(vect.begin(), vect.end(), 6);
+ qLowerBound(vect.begin(), vect.end(), 6);
QVector<int>::iterator end6 =
- qUpperBound(vect.begin(), vect.end(), 6);
+ qUpperBound(vect.begin(), vect.end(), 6);
QVector<int>::iterator i = begin6;
while (i != end6) {
@@ -323,7 +323,7 @@ QVector<int> vect;
vect << 3 << 3 << 6 << 6 << 6 << 8;
QVector<int>::iterator i =
- qBinaryFind(vect.begin(), vect.end(), 6);
+ qBinaryFind(vect.begin(), vect.end(), 6);
// i == vect.begin() + 2 (or 3 or 4)
//! [22]
diff --git a/src/corelib/doc/snippets/code/doc_src_qiterator.cpp b/src/corelib/doc/snippets/code/doc_src_qiterator.cpp
index af8f87b1c6..eec7a96a38 100644
--- a/src/corelib/doc/snippets/code/doc_src_qiterator.cpp
+++ b/src/corelib/doc/snippets/code/doc_src_qiterator.cpp
@@ -218,7 +218,7 @@ QMutableListIterator<int> i(list);
while (i.hasNext()) {
int val = i.next();
if (val < -32768 || val > 32767)
- i.remove();
+ i.remove();
}
//! [19]
@@ -228,7 +228,7 @@ QMutableLinkedListIterator<int> i(list);
while (i.hasNext()) {
int val = i.next();
if (val < -32768 || val > 32767)
- i.remove();
+ i.remove();
}
//! [20]
@@ -238,7 +238,7 @@ QMutableVectorIterator<int> i(vector);
while (i.hasNext()) {
int val = i.next();
if (val < -32768 || val > 32767)
- i.remove();
+ i.remove();
}
//! [21]
@@ -248,7 +248,7 @@ QMutableSetIterator<int> i(set);
while (i.hasNext()) {
int val = i.next();
if (val < -32768 || val > 32767)
- i.remove();
+ i.remove();
}
//! [22]
@@ -305,7 +305,7 @@ while (i.hasPrevious()) {
QMapIterator<int, QWidget *> i(map);
while (i.findNext(widget)) {
qDebug() << "Found widget " << widget << " under key "
- << i.key();
+ << i.key();
}
//! [28]
@@ -335,7 +335,7 @@ while (i.hasPrevious()) {
QHashIterator<int, QWidget *> i(hash);
while (i.findNext(widget)) {
qDebug() << "Found widget " << widget << " under key "
- << i.key();
+ << i.key();
}
//! [31]
@@ -365,7 +365,7 @@ while (i.hasPrevious()) {
QMutableMapIterator<int, QWidget *> i(map);
while (i.findNext(widget)) {
qDebug() << "Found widget " << widget << " under key "
- << i.key();
+ << i.key();
}
//! [34]
@@ -405,7 +405,7 @@ while (i.hasPrevious()) {
QMutableHashIterator<int, QWidget *> i(hash);
while (i.findNext(widget)) {
qDebug() << "Found widget " << widget << " under key "
- << i.key();
+ << i.key();
}
//! [38]
diff --git a/src/corelib/doc/snippets/code/qlogging/qlogging.cpp b/src/corelib/doc/snippets/code/qlogging/qlogging.cpp
index 774610a3c0..d3b9e1fd14 100644
--- a/src/corelib/doc/snippets/code/qlogging/qlogging.cpp
+++ b/src/corelib/doc/snippets/code/qlogging/qlogging.cpp
@@ -52,3 +52,7 @@
}
}
//! [1]
+
+//! [2]
+ QLoggingCategory &category();
+//! [2]
diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
index 59f05592be..3a18eb8007 100644
--- a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
@@ -523,10 +523,10 @@ class MyClass : public QObject
//! [45]
//! [46]
- // Instead of comparing with 0.0
- qFuzzyCompare(0.0,1.0e-200); // This will return false
- // Compare adding 1 to both values will fix the problem
- qFuzzyCompare(1 + 0.0, 1 + 1.0e-200); // This will return true
+ // Instead of comparing with 0.0
+ qFuzzyCompare(0.0,1.0e-200); // This will return false
+ // Compare adding 1 to both values will fix the problem
+ qFuzzyCompare(1 + 0.0, 1 + 1.0e-200); // This will return true
//! [46]
//! [47]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qstringiterator.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qstringiterator.cpp
new file mode 100644
index 0000000000..178c6feb0a
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qstringiterator.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QString>
+#include <QStringIterator>
+#include <QDebug>
+
+int main()
+{
+
+{
+//! [0]
+QString string(QStringLiteral("a string"));
+QStringIterator i(string);
+//! [0]
+
+//! [1]
+// will print 97, 32, 115, 116, etc.;
+// that is, the decimal value of the code points in the Unicode string "a string"
+while (i.hasNext())
+ qDebug() << i.next();
+//! [1]
+}
+
+{
+//! [2]
+QString string(QStringLiteral("𝄞 is the G clef"));
+QStringIterator i(string);
+qDebug() << hex << i.next(); // will print 1d11e (U+1D11E, MUSICAL SYMBOL G CLEF)
+qDebug() << hex << i.next(); // will print 20 (U+0020, SPACE)
+qDebug() << hex << i.next(); // will print 69 (U+0069, LATIN SMALL LETTER I)
+//! [2]
+}
+
+}