summaryrefslogtreecommitdiffstats
path: root/src/corelib/doc
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/doc')
-rw-r--r--src/corelib/doc/qtcore.qdocconf3
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_animation_qparallelanimationgroup.cpp57
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_animation_qpropertyanimation.cpp59
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_animation_qsequentialanimationgroup.cpp58
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_animation_qvariantanimation.cpp63
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp107
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_global_qlogging.cpp53
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_global_qnumeric.cpp56
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_global_qoperatingsystemversion.cpp61
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_global_qrandom.cpp131
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_io_qdebug.cpp95
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_io_qfileselector.cpp93
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_io_qloggingcategory.cpp68
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_io_qstorageinfo.cpp49
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_io_qtemporaryfile.cpp8
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_io_qurl.cpp86
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_io_qurlquery.cpp54
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qdeadlinetimer.cpp134
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qmetaobject.cpp19
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp13
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_mimetype_qmimedatabase.cpp15
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_serialization_qcborstream.cpp358
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_serialization_qcborvalue.cpp80
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_serialization_qdatastream.cpp59
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_serialization_qjsondocument.cpp65
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_thread_qsemaphore.cpp29
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp27
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qbytearraymatcher.cpp57
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qcontiguouscache.cpp70
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp20
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp2
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qrect.cpp10
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qregularexpression.cpp8
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qscopeguard.cpp2
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qshareddata.cpp66
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qsharedpointer.cpp157
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qstring.cpp18
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qstringview.cpp62
-rw-r--r--src/corelib/doc/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp2
-rw-r--r--src/corelib/doc/snippets/hellotrmain.cpp2
-rw-r--r--src/corelib/doc/snippets/qbytearraylist/main.cpp51
-rw-r--r--src/corelib/doc/snippets/qelapsedtimer/main.cpp2
-rw-r--r--src/corelib/doc/snippets/qloggingcategory/main.cpp2
-rw-r--r--src/corelib/doc/snippets/resource-system/mainwindow.cpp10
-rw-r--r--src/corelib/doc/snippets/signalsandslots/lcdnumber.h2
-rw-r--r--src/corelib/doc/snippets/timers/analogclock.cpp2
-rw-r--r--src/corelib/doc/src/containers.qdoc5
-rw-r--r--src/corelib/doc/src/datastreamformat.qdoc402
-rw-r--r--src/corelib/doc/src/external-resources.qdoc8
-rw-r--r--src/corelib/doc/src/objectmodel/metaobjects.qdoc2
-rw-r--r--src/corelib/doc/src/objectmodel/signalsandslots.qdoc4
-rw-r--r--src/corelib/doc/src/resource-system.qdoc67
52 files changed, 2496 insertions, 437 deletions
diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf
index 5a42e21845..85dcde4607 100644
--- a/src/corelib/doc/qtcore.qdocconf
+++ b/src/corelib/doc/qtcore.qdocconf
@@ -45,6 +45,9 @@ excludedirs += snippets
excludefiles += ../../../examples/widgets/tools/customcompleter/doc/src/customcompleter.qdoc \
../../../examples/widgets/tools/codecs/doc/src/codecs.qdoc
+# Included in qttestlib.qdocconf instead
+excludefiles += ../kernel/qtestsupport_core.cpp
+
manifestmeta.highlighted.names = "QtCore/JSON Save Game Example" \
"QtCore/Local Fortune*"
diff --git a/src/corelib/doc/snippets/code/src_corelib_animation_qparallelanimationgroup.cpp b/src/corelib/doc/snippets/code/src_corelib_animation_qparallelanimationgroup.cpp
new file mode 100644
index 0000000000..472c5d41c4
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_animation_qparallelanimationgroup.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+//! [0]
+ QParallelAnimationGroup *group = new QParallelAnimationGroup;
+ group->addAnimation(anim1);
+ group->addAnimation(anim2);
+
+ group->start();
+//! [0]
diff --git a/src/corelib/doc/snippets/code/src_corelib_animation_qpropertyanimation.cpp b/src/corelib/doc/snippets/code/src_corelib_animation_qpropertyanimation.cpp
new file mode 100644
index 0000000000..7bd8121b90
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_animation_qpropertyanimation.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+
+//! [0]
+ QPropertyAnimation *animation = new QPropertyAnimation(myWidget, "geometry");
+ animation->setDuration(10000);
+ animation->setStartValue(QRect(0, 0, 100, 30));
+ animation->setEndValue(QRect(250, 250, 100, 30));
+
+ animation->start();
+//! [0]
diff --git a/src/corelib/doc/snippets/code/src_corelib_animation_qsequentialanimationgroup.cpp b/src/corelib/doc/snippets/code/src_corelib_animation_qsequentialanimationgroup.cpp
new file mode 100644
index 0000000000..0eff184926
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_animation_qsequentialanimationgroup.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+//! [0]
+ QSequentialAnimationGroup *group = new QSequentialAnimationGroup;
+
+ group->addAnimation(anim1);
+ group->addAnimation(anim2);
+
+ group->start();
+//! [0]
diff --git a/src/corelib/doc/snippets/code/src_corelib_animation_qvariantanimation.cpp b/src/corelib/doc/snippets/code/src_corelib_animation_qvariantanimation.cpp
new file mode 100644
index 0000000000..0808dcc145
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_animation_qvariantanimation.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+//! [0]
+ QVariant myColorInterpolator(const QColor &start, const QColor &end, qreal progress)
+ {
+ ...
+ return QColor(...);
+ }
+ ...
+ qRegisterAnimationInterpolator<QColor>(myColorInterpolator);
+//! [0]
+
+//! [1]
+ QVariant myInterpolator(const QVariant &from, const QVariant &to, qreal progress);
+//! [1]
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 9d029e5d4d..eb75a29ca2 100644
--- a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
@@ -279,21 +279,23 @@ const TInputType &myMin(const TInputType &value1, const TInputType &value2)
void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
QByteArray localMsg = msg.toLocal8Bit();
+ const char *file = context.file ? context.file : "";
+ const char *function = context.function ? context.function : "";
switch (type) {
case QtDebugMsg:
- fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
+ fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function);
break;
case QtInfoMsg:
- fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
+ fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function);
break;
case QtWarningMsg:
- fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
+ fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function);
break;
case QtCriticalMsg:
- fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
+ fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function);
break;
case QtFatalMsg:
- fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
+ fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function);
break;
}
}
@@ -595,8 +597,7 @@ namespace QT_NAMESPACE {
//! [43]
class MyClass : public QObject
{
-
- private:
+private:
Q_DISABLE_COPY(MyClass)
};
@@ -605,22 +606,21 @@ class MyClass : public QObject
//! [44]
class MyClass : public QObject
{
-
- private:
- MyClass(const MyClass &);
- MyClass &operator=(const MyClass &);
+private:
+ MyClass(const MyClass &) = delete;
+ MyClass &operator=(const MyClass &) = delete;
};
//! [44]
//! [45]
- QWidget w = QWidget();
+QWidget w = QWidget();
//! [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]
@@ -649,24 +649,24 @@ template<> class QTypeInfo<A> : public QTypeInfoMerger<A, B, C, D> {};
//! [52]
struct Foo {
void overloadedFunction();
- void overloadedFunction(int, QString);
+ void overloadedFunction(int, const QString &);
};
... qOverload<>(&Foo::overloadedFunction)
- ... qOverload<int, QString>(&Foo::overloadedFunction)
+ ... qOverload<int, const QString &>(&Foo::overloadedFunction)
//! [52]
//! [53]
... QOverload<>::of(&Foo::overloadedFunction)
- ... QOverload<int, QString>::of(&Foo::overloadedFunction)
+ ... QOverload<int, const QString &>::of(&Foo::overloadedFunction)
//! [53]
//! [54]
struct Foo {
- void overloadedFunction(int, QString);
- void overloadedFunction(int, QString) const;
+ void overloadedFunction(int, const QString &);
+ void overloadedFunction(int, const QString &) const;
};
- ... qConstOverload<int, QString>(&Foo::overloadedFunction)
- ... qNonConstOverload<int, QString>(&Foo::overloadedFunction)
+ ... qConstOverload<int, const QString &>(&Foo::overloadedFunction)
+ ... qNonConstOverload<int, const QString &>(&Foo::overloadedFunction)
//! [54]
//! [qlikely]
@@ -725,3 +725,64 @@ bool readConfiguration(const QFile &file)
#include <QtGui>
#endif
//! [qt-version-check]
+
+//! [is-empty]
+ qgetenv(varName).isEmpty()
+//! [is-empty]
+
+//! [to-int]
+ qgetenv(varName).toInt(ok, 0)
+//! [to-int]
+
+//! [is-null]
+ !qgetenv(varName).isNull()
+//! [is-null]
+
+//! [as-const-0]
+ QString s = ...;
+ for (QChar ch : s) // detaches 's' (performs a deep-copy if 's' was shared)
+ process(ch);
+ for (QChar ch : qAsConst(s)) // ok, no detach attempt
+ process(ch);
+//! [as-const-0]
+
+//! [as-const-1]
+ const QString s = ...;
+ for (QChar ch : s) // ok, no detach attempt on const objects
+ process(ch);
+//! [as-const-1]
+
+//! [as-const-2]
+ for (QChar ch : funcReturningQString())
+ process(ch); // OK, the returned object is kept alive for the loop's duration
+//! [as-const-2]
+
+//! [as-const-3]
+ for (QChar ch : qAsConst(funcReturningQString()))
+ process(ch); // ERROR: ch is copied from deleted memory
+//! [as-const-3]
+
+//! [as-const-4]
+ for (QChar ch : qAsConst(funcReturningQString()))
+ process(ch); // ERROR: ch is copied from deleted memory
+//! [as-const-4]
+
+//! [qterminate]
+ try { expr; } catch(...) { qTerminate(); }
+//! [qterminate]
+
+//! [qdecloverride]
+ // generate error if this doesn't actually override anything:
+ virtual void MyWidget::paintEvent(QPaintEvent*) override;
+//! [qdecloverride]
+
+//! [qdeclfinal-1]
+ // more-derived classes no longer permitted to override this:
+ virtual void MyWidget::paintEvent(QPaintEvent*) final;
+//! [qdeclfinal-1]
+
+//! [qdeclfinal-2]
+ class QRect final { // cannot be derived from
+ // ...
+ };
+//! [qdeclfinal-2]
diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qlogging.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qlogging.cpp
new file mode 100644
index 0000000000..7589050bc2
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_global_qlogging.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+//! [0]
+ QT_MESSAGE_PATTERN="[%{time yyyyMMdd h:mm:ss.zzz t} %{if-debug}D%{endif}%{if-info}I%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{file}:%{line} - %{message}"
+//! [0]
diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qnumeric.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qnumeric.cpp
new file mode 100644
index 0000000000..d281089041
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_global_qnumeric.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+//! [0]
+ if (qFloatDistance(a, b) < (1 << 7)) { // The last 7 bits are not
+ // significant
+ // precise enough
+ }
+//! [0]
diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qoperatingsystemversion.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qoperatingsystemversion.cpp
new file mode 100644
index 0000000000..c712dfa432
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_global_qoperatingsystemversion.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+//! [0]
+ QOperatingSystemVersion::current() >= QOperatingSystemVersion(QOperatingSystemVersion::IOS, 9)
+//! [0]
+
+//! [1]
+ auto current = QOperatingSystemVersion::current();
+ if (current >= QOperatingSystemVersion::OSXYosemite ||
+ current >= QOperatingSystemVersion(QOperatingSystemVersion::IOS, 8)) {
+ // returns true on macOS >= 10.10 and iOS >= 8.0, but false on macOS < 10.10 and iOS < 8.0
+ }
+//! [1]
diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qrandom.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qrandom.cpp
new file mode 100644
index 0000000000..6e47a7a3d9
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_global_qrandom.cpp
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Intel Corporation.
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+//! [0]
+ quint32 value = QRandomGenerator::global()->generate();
+//! [0]
+
+//! [1]
+ QRandomGenerator prng1(1234), prng2(1234);
+ Q_ASSERT(prng1.generate() == prng2.generate());
+ Q_ASSERT(prng1.generate64() == prng2.generate64());
+//! [1]
+
+//! [2]
+ int x = QRandomGenerator::global()->generate();
+ int y = QRandomGenerator::global()->generate();
+ int w = QRandomGenerator::global()->bounded(16384);
+ int h = QRandomGenerator::global()->bounded(16384);
+//! [2]
+
+//! [3]
+ std::uniform_real_distribution dist(1, 2.5);
+ return dist(*QRandomGenerator::global());
+//! [3]
+
+//! [4]
+ std::seed_seq sseq(seedBuffer, seedBuffer + len);
+ QRandomGenerator generator(sseq);
+//! [4]
+
+//! [5]
+ std::seed_seq sseq(begin, end);
+ QRandomGenerator generator(sseq);
+//! [5]
+
+//! [6]
+ while (z--)
+ generator.generate();
+//! [6]
+
+//! [7]
+ std::generate(begin, end, [this]() { return generate(); });
+//! [7]
+
+//! [8]
+ std::generate(begin, end, []() { return QRandomGenerator::global()->generate64(); });
+//! [8]
+
+//! [9]
+ QVector<quint32> vector;
+ vector.resize(16);
+ QRandomGenerator::fillRange(vector.data(), vector.size());
+//! [9]
+
+//! [10]
+ quint32 array[2];
+ QRandomGenerator::fillRange(array);
+//! [10]
+
+//! [11]
+ QRandomGenerator64 rd;
+ return std::generate_canonical<qreal, std::numeric_limits<qreal>::digits>(rd);
+//! [11]
+
+//! [12]
+ return generateDouble() * highest;
+//! [12]
+
+//! [13]
+ quint32 v = QRandomGenerator::bounded(256);
+//! [13]
+
+//! [14]
+ quint32 v = QRandomGenerator::bounded(1000, 2000);
+//! [14]
+
+//! [15]
+ return QColor::fromRgb(QRandomGenerator::global()->generate());
+//! [15]
+
+//! [16]
+ qint64 value = QRandomGenerator64::generate() & std::numeric_limits<qint64>::max();
+//! [16]
diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qdebug.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qdebug.cpp
new file mode 100644
index 0000000000..14e72e99dd
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_io_qdebug.cpp
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+//! [0]
+ QString s;
+
+ s = "a";
+ qDebug().noquote() << s; // prints: a
+ qDebug() << s; // prints: "a"
+
+ s = "\"a\r\n\"";
+ qDebug() << s; // prints: "\"a\r\n\""
+
+ s = "\033"; // escape character
+ qDebug() << s; // prints: "\u001B"
+
+ s = "\u00AD"; // SOFT HYPHEN
+ qDebug() << s; // prints: "\u00AD"
+
+ s = "\u00E1"; // LATIN SMALL LETTER A WITH ACUTE
+ qDebug() << s; // prints: "á"
+
+ s = "a\u0301"; // "a" followed by COMBINING ACUTE ACCENT
+ qDebug() << s; // prints: "á";
+
+ s = "\u0430\u0301"; // CYRILLIC SMALL LETTER A followed by COMBINING ACUTE ACCENT
+ qDebug() << s; // prints: "а́"
+//! [0]
+
+//! [1]
+ QByteArray ba;
+
+ ba = "a";
+ qDebug().noquote() << ba; // prints: a
+ qDebug() << ba; // prints: "a"
+
+ ba = "\"a\r\n\"";
+ qDebug() << ba; // prints: "\"a\r\n\""
+
+ ba = "\033"; // escape character
+ qDebug() << ba; // prints: "\x1B"
+
+ ba = "\xC3\xA1";
+ qDebug() << ba; // prints: "\xC3\xA1"
+
+ ba = QByteArray("a\0b", 3);
+ qDebug() << ba // prints: "\a\x00""b"
+//! [1]
diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qfileselector.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qfileselector.cpp
new file mode 100644
index 0000000000..0d1aa691cf
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_io_qfileselector.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+//! [0]
+ QString defaultsBasePath = "data/";
+ QString defaultsPath = defaultsBasePath + "defaults.conf";
+ QString localizedPath = defaultsBasePath
+ + QString("%1/defaults.conf").arg(QLocale().name());
+ if (QFile::exists(localizedPath))
+ defaultsPath = localizedPath;
+ QFile defaults(defaultsPath);
+//! [0]
+
+//! [1]
+ QString defaultsPath = "data/defaults.conf";
+#if defined(Q_OS_ANDROID)
+ defaultsPath = "data/android/defaults.conf";
+#elif defined(Q_OS_IOS)
+ defaultsPath = "data/ios/defaults.conf";
+#endif
+ QFile defaults(defaultsPath);
+//! [1]
+
+//! [2]
+ QFileSelector selector;
+ QFile defaultsFile(selector.select("data/defaults.conf"));
+//! [2]
+
+//! [3]
+ data/defaults.conf
+ data/+android/defaults.conf
+ data/+ios/+en_GB/defaults.conf
+//! [3]
+
+//! [4]
+ images/background.png
+ images/+android/+en_GB/background.png
+//! [4]
+
+//! [5]
+ images/background.png
+ images/+linux/background.png
+ images/+windows/background.png
+ images/+admin/background.png
+ images/+admin/+linux/background.png
+//! [5]
diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qloggingcategory.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qloggingcategory.cpp
new file mode 100644
index 0000000000..cab48f1e27
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_io_qloggingcategory.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+//! [0]
+ <category>[.<type>] = true|false
+//! [0]
+
+//! [1]
+ QLoggingCategory::setFilterRules("*.debug=false\n"
+ "driver.usb.debug=true");
+//! [1]
+
+//! [2]
+ [Rules]
+ *.debug=false
+ driver.usb.debug=true
+//! [2]
+
+//! [3]
+ QT_LOGGING_RULES="*.debug=false;driver.usb.debug=true"
+//! [3]
diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qstorageinfo.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qstorageinfo.cpp
index e0594433ff..c7a1b34f7a 100644
--- a/src/corelib/doc/snippets/code/src_corelib_io_qstorageinfo.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_io_qstorageinfo.cpp
@@ -3,9 +3,9 @@
** Copyright (C) 2014 Ivan Komissarov
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the QtCore module of the Qt Toolkit.
+** This file is part of the documentation of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL$
+** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -14,24 +14,35 @@
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
+** "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 The Qt Company Ltd 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$
**
diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qtemporaryfile.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qtemporaryfile.cpp
index 127c7bd0d9..4e864b3dcd 100644
--- a/src/corelib/doc/snippets/code/src_corelib_io_qtemporaryfile.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_io_qtemporaryfile.cpp
@@ -61,3 +61,11 @@
// as it goes out of scope.
//! [0]
}
+
+//! [1]
+ QFile f(":/resources/file.txt");
+ QTemporaryFile::createNativeFile(f); // Returns a pointer to a temporary file
+
+ QFile f("/users/qt/file.txt");
+ QTemporaryFile::createNativeFile(f); // Returns 0
+//! [1]
diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qurl.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qurl.cpp
index b2a2282085..79af776ce4 100644
--- a/src/corelib/doc/snippets/code/src_corelib_io_qurl.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_io_qurl.cpp
@@ -101,3 +101,89 @@ QUrl url("http://qt-project.org/support/file.html");
// url.adjusted(RemoveFilename) == "http://qt-project.org/support/"
// url.fileName() == "file.html"
//! [7]
+
+//! [8]
+ qDebug() << QUrl("main.qml").isRelative(); // true: no scheme
+ qDebug() << QUrl("qml/main.qml").isRelative(); // true: no scheme
+ qDebug() << QUrl("file:main.qml").isRelative(); // false: has "file" scheme
+ qDebug() << QUrl("file:qml/main.qml").isRelative(); // false: has "file" scheme
+//! [8]
+
+//! [9]
+ // Absolute URL, relative path
+ QUrl url("file:file.txt");
+ qDebug() << url.isRelative(); // false: has "file" scheme
+ qDebug() << QDir::isAbsolutePath(url.path()); // false: relative path
+
+ // Relative URL, absolute path
+ url = QUrl("/home/user/file.txt");
+ qDebug() << url.isRelative(); // true: has no scheme
+ qDebug() << QDir::isAbsolutePath(url.path()); // true: absolute path
+//! [9]
+
+//! [10]
+ QUrl original("http://example.com/?q=a%2B%3Db%26c");
+ QUrl copy(original);
+ copy.setQuery(copy.query(QUrl::FullyDecoded), QUrl::DecodedMode);
+
+ qDebug() << original.toString(); // prints: http://example.com/?q=a%2B%3Db%26c
+ qDebug() << copy.toString(); // prints: http://example.com/?q=a+=b&c
+//! [10]
+
+//! [11]
+ QUrl url;
+ url.setScheme("ftp");
+//! [11]
+
+//! [12]
+ qDebug() << QUrl("file:file.txt").path(); // "file.txt"
+ qDebug() << QUrl("/home/user/file.txt").path(); // "/home/user/file.txt"
+ qDebug() << QUrl("http://www.example.com/test/123").path(); // "/test/123"
+//! [12]
+
+//! [13]
+ qDebug() << QUrl("/foo%FFbar").path();
+//! [13]
+
+//! [14]
+ qDebug() << QUrl("/foo+bar%2B").path(); // "/foo+bar+"
+//! [14]
+
+//! [15]
+ const QUrl url("/tmp/Mambo %235%3F.mp3");
+ qDebug() << url.path(QUrl::FullyDecoded); // "/tmp/Mambo #5?.mp3"
+ qDebug() << url.path(QUrl::PrettyDecoded); // "/tmp/Mambo #5?.mp3"
+ qDebug() << url.path(QUrl::FullyEncoded); // "/tmp/Mambo%20%235%3F.mp3"
+//! [15]
+
+//! [16]
+ qDebug() << QUrl::fromLocalFile("file.txt"); // QUrl("file:file.txt")
+ qDebug() << QUrl::fromLocalFile("/home/user/file.txt"); // QUrl("file:///home/user/file.txt")
+ qDebug() << QUrl::fromLocalFile("file:file.txt"); // doesn't make sense; expects path, not url with scheme
+//! [16]
+
+//! [17]
+ QUrl url = QUrl::fromLocalFile("file.txt");
+ QUrl baseUrl = QUrl("file:/home/user/");
+ // wrong: prints QUrl("file:file.txt"), as url already has a scheme
+ qDebug() << baseUrl.resolved(url);
+//! [17]
+
+//! [18]
+ // correct: prints QUrl("file:///home/user/file.txt")
+ url.setScheme(QString());
+ qDebug() << baseUrl.resolved(url);
+//! [18]
+
+//! [19]
+ QUrl url = QUrl("file.txt");
+ QUrl baseUrl = QUrl("file:/home/user/");
+ // prints QUrl("file:///home/user/file.txt")
+ qDebug() << baseUrl.resolved(url);
+//! [19]
+
+//! [20]
+ qDebug() << QUrl("file:file.txt").toLocalFile(); // "file:file.txt"
+ qDebug() << QUrl("file:/home/user/file.txt").toLocalFile(); // "file:///home/user/file.txt"
+ qDebug() << QUrl("file.txt").toLocalFile(); // ""; wasn't a local file as it had no scheme
+//! [20]
diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qurlquery.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qurlquery.cpp
new file mode 100644
index 0000000000..22f1d3260f
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_io_qurlquery.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+//! [0]
+sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
+ / "*" / "+" / "," / ";" / "="
+//! [0]
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qdeadlinetimer.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qdeadlinetimer.cpp
new file mode 100644
index 0000000000..35c06f842e
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qdeadlinetimer.cpp
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+//! [0]
+ void executeOperation(int msecs)
+ {
+ QDeadlineTimer deadline(msecs);
+ do {
+ if (readFromDevice(deadline.remainingTime())
+ break;
+ waitForReadyRead(deadline);
+ } while (!deadline.hasExpired());
+ }
+//! [0]
+
+//! [1]
+ using namespace std::chrono;
+ using namespace std::chrono_literals;
+
+ QDeadlineTimer deadline(30s);
+ device->waitForReadyRead(deadline);
+ if (deadline.remainingTime<nanoseconds>() > 300ms)
+ cleanup();
+//! [1]
+
+//! [2]
+ using namespace std::chrono;
+ using namespace std::chrono_literals;
+ auto now = steady_clock::now();
+ QDeadlineTimer deadline(now + 1s);
+ Q_ASSERT(deadline == now + 1s);
+//! [2]
+
+//! [3]
+ using namespace std::chrono_literals;
+ QDeadlineTimer deadline(250ms);
+//! [3]
+
+//! [4]
+ using namespace std::chrono_literals;
+ deadline.setRemainingTime(250ms);
+//! [4]
+
+//! [5]
+ mutex.tryLock(deadline.remainingTime());
+//! [5]
+
+//! [6]
+ qint64 realTimeLeft = deadline.deadline();
+ if (realTimeLeft != (std::numeric_limits<qint64>::max)()) {
+ realTimeLeft -= QDeadlineTimer::current().deadline();
+ // or:
+ //QElapsedTimer timer;
+ //timer.start();
+ //realTimeLeft -= timer.msecsSinceReference();
+ }
+//! [6]
+
+//! [7]
+ qint64 realTimeLeft = deadline.deadlineNSecs();
+ if (realTimeLeft != std::numeric_limits<qint64>::max())
+ realTimeLeft -= QDeadlineTimer::current().deadlineNSecs();
+//! [7]
+
+//! [8]
+ return d1.deadlineNSecs() == d2.deadlineNSecs();
+//! [8]
+
+//! [9]
+ return d1.deadlineNSecs() != d2.deadlineNSecs();
+//! [9]
+
+//! [10]
+ return d1.deadlineNSecs() < d2.deadlineNSecs();
+//! [10]
+
+//! [11]
+ return d1.deadlineNSecs() <= d2.deadlineNSecs();
+//! [11]
+
+//! [12]
+ return d1.deadlineNSecs() > d2.deadlineNSecs();
+//! [12]
+
+//! [13]
+ return d1.deadlineNSecs() >= d2.deadlineNSecs();
+//! [13]
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qmetaobject.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qmetaobject.cpp
index eda52cfacd..56d1fa5a63 100644
--- a/src/corelib/doc/snippets/code/src_corelib_kernel_qmetaobject.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qmetaobject.cpp
@@ -147,4 +147,23 @@ method.invoke(obj,
QMetaMethod destroyedSignal = QMetaMethod::fromSignal(&QObject::destroyed);
//! [9]
+//! [10]
+ // In the class MainWindow declaration
+ #ifndef Q_MOC_RUN
+ // define the tag text as empty, so the compiler doesn't see it
+ # define MY_CUSTOM_TAG
+ #endif
+ ...
+ private slots:
+ MY_CUSTOM_TAG void testFunc();
+//! [10]
+
+//! [11]
+ MainWindow win;
+ win.show();
+
+ int functionIndex = win.metaObject()->indexOfSlot("testFunc()");
+ QMetaMethod mm = win.metaObject()->method(functionIndex);
+ qDebug() << mm.tag(); // prints MY_CUSTOM_TAG
+//! [11]
}
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp
index 6451f46b36..1e31a5292f 100644
--- a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp
@@ -538,3 +538,16 @@ QString text = MyMagicClass::tr("Sim sala bim.");
//! [explicit tr context]
QString text = QScrollBar::tr("Page up");
//! [explicit tr context]
+
+//! [53]
+{
+const QSignalBlocker blocker(someQObject);
+// no signals here
+}
+//! [53]
+
+//! [54]
+const bool wasBlocked = someQObject->blockSignals(true);
+// no signals here
+someQObject->blockSignals(wasBlocked);
+//! [54]
diff --git a/src/corelib/doc/snippets/code/src_corelib_mimetype_qmimedatabase.cpp b/src/corelib/doc/snippets/code/src_corelib_mimetype_qmimedatabase.cpp
index c5874d83b8..3092e32f6f 100644
--- a/src/corelib/doc/snippets/code/src_corelib_mimetype_qmimedatabase.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_mimetype_qmimedatabase.cpp
@@ -55,3 +55,18 @@ if (mime.inherits("text/plain")) {
// The file is plain text, we can display it in a QTextEdit
}
//! [0]
+
+//! [1]
+QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/packages"),
+ QStandardPaths::LocateDirectory);
+//! [1]
+
+//! [2]
+<?xml version="1.0" encoding="UTF-8"?>
+<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
+ <mime-type type="application/vnd.qt.qmakeprofile">
+ <comment xml:lang="en">Qt qmake Profile</comment>
+ <glob pattern="*.pro" weight="50"/>
+ </mime-type>
+</mime-info>
+//! [2]
diff --git a/src/corelib/doc/snippets/code/src_corelib_serialization_qcborstream.cpp b/src/corelib/doc/snippets/code/src_corelib_serialization_qcborstream.cpp
new file mode 100644
index 0000000000..6ddb5a9365
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_serialization_qcborstream.cpp
@@ -0,0 +1,358 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+//! [0]
+ QCborValue(QCborTag(2), QByteArray("\x01\0\0\0\0\0\0\0\0", 9));
+//! [0]
+
+//! [1]
+ writer.startMap(4); // 4 elements in the map
+
+ writer.append(QLatin1String("label"));
+ writer.append(QLatin1String("journald"));
+
+ writer.append(QLatin1String("autoDetect"));
+ writer.append(false);
+
+ writer.append(QLatin1String("condition"));
+ writer.append(QLatin1String("libs.journald"));
+
+ writer.append(QLatin1String("output"));
+ writer.startArray(1);
+ writer.append(QLatin1String("privateFeature"));
+ writer.endArray();
+
+ writer.endMap();
+//! [1]
+
+//! [2]
+ QFile f("output", QIODevice::WriteOnly);
+ QCborStreamWriter writer(&f);
+ writer.startMap(0);
+ writer.endMap();
+//! [2]
+
+//! [3]
+ QByteArray encodedNumber(qint64 value)
+ {
+ QByteArray ba;
+ QCborStreamWriter writer(&ba);
+ writer.append(value);
+ return ba;
+ }
+//! [3]
+
+//! [4]
+ writer.append(0U);
+ writer.append(Q_UINT64_C(4294967296));
+ writer.append(std::numeric_limits<quint64>::max());
+//! [4]
+
+//! [5]
+ writer.append(0);
+ writer.append(-1);
+ writer.append(Q_INT64_C(4294967296));
+ writer.append(std::numeric_limits<qint64>::max());
+//! [5]
+
+//! [6]
+ writer.append(QCborNegativeInteger(1));
+ writer.append(QCborNegativeInteger(Q_INT64_C(4294967296)));
+ writer.append(QCborNegativeInteger(-quint64(std::numeric_limits<qint64>::min())));
+//! [6]
+
+//! [7]
+ void writeFile(QCborStreamWriter &writer, const QString &fileName)
+ {
+ QFile f(fileName);
+ if (f.open(QIODevice::ReadOnly))
+ writer.append(f.readAll());
+ }
+//! [7]
+
+//! [8]
+ writer.append(QLatin1String("Hello, World"));
+//! [8]
+
+//! [9]
+ void writeString(QCborStreamWriter &writer, const QString &str)
+ {
+ writer.append(str);
+ }
+//! [9]
+
+//! [10]
+ void writeRxPattern(QCborStreamWriter &writer, const QRegularExpression &rx)
+ {
+ writer.append(QCborTag(36));
+ writer.append(rx.pattern());
+ }
+//! [10]
+
+//! [11]
+ void writeCurrentTime(QCborStreamWriter &writer)
+ {
+ writer.append(QCborKnownTags::UnixTime_t);
+ writer.append(time(nullptr));
+ }
+//! [11]
+
+//! [12]
+ writer.append(QCborSimpleType::Null);
+ writer.append(QCborSimpleType(32));
+//! [12]
+
+//! [13]
+ void writeFloat(QCborStreamWriter &writer, float f)
+ {
+ qfloat16 f16 = f;
+ if (qIsNaN(f) || f16 == f)
+ writer.append(f16);
+ else
+ writer.append(f);
+ }
+//! [13]
+
+//! [14]
+ void writeFloat(QCborStreamWriter &writer, double d)
+ {
+ float f = d;
+ if (qIsNaN(d) || d == f)
+ writer.append(f);
+ else
+ writer.append(d);
+ }
+//! [14]
+
+//! [15]
+ void writeDouble(QCborStreamWriter &writer, double d)
+ {
+ float f;
+ if (qIsNaN(d)) {
+ writer.append(qfloat16(qQNaN()));
+ } else if (qIsInf(d)) {
+ writer.append(d < 0 ? -qInf() : qInf());
+ } else if ((f = d) == d) {
+ qfloat16 f16 = f;
+ if (f16 == f)
+ writer.append(f16);
+ else
+ writer.append(f);
+ } else {
+ writer.append(d);
+ }
+ }
+//! [15]
+
+//! [16]
+ writer.append(b ? QCborSimpleType::True : QCborSimpleType::False);
+//! [16]
+
+//! [17]
+ writer.append(QCborSimpleType::Null);
+//! [17]
+
+//! [18]
+ writer.append(QCborSimpleType::Null);
+//! [18]
+
+//! [19]
+ writer.append(QCborSimpleType::Undefined);
+//! [19]
+
+//! [20]
+ void appendList(QCborStreamWriter &writer, const QLinkedList<QString> &list)
+ {
+ writer.startArray();
+ for (const QString &s : list)
+ writer.append(s);
+ writer.endArray();
+ }
+//! [20]
+
+//! [21]
+ void appendList(QCborStreamWriter &writer, const QStringList &list)
+ {
+ writer.startArray(list.size());
+ for (const QString &s : list)
+ writer.append(s);
+ writer.endArray();
+ }
+//! [21]
+
+//! [22]
+ void appendMap(QCborStreamWriter &writer, const QLinkedList<QPair<int, QString>> &list)
+ {
+ writer.startMap();
+ for (const auto pair : list) {
+ writer.append(pair.first)
+ writer.append(pair.second);
+ }
+ writer.endMap();
+ }
+//! [22]
+
+//! [23]
+ void appendMap(QCborStreamWriter &writer, const QMap<int, QString> &map)
+ {
+ writer.startMap(map.size());
+ for (auto it = map.begin(); it != map.end(); ++it) {
+ writer.append(it.key());
+ writer.append(it.value());
+ }
+ writer.endMap();
+ }
+//! [23]
+
+//! [24]
+ void handleStream(QCborStreamReader &reader)
+ {
+ switch (reader.type())
+ case QCborStreamReader::UnsignedInteger:
+ case QCborStreamReader::NegativeInteger:
+ case QCborStreamReader::SimpleType:
+ case QCborStreamReader::Float16:
+ case QCborStreamReader::Float:
+ case QCborStreamReader::Double:
+ handleFixedWidth(reader);
+ reader.next();
+ break;
+ case QCborStreamReader::ByteArray:
+ case QCborStreamReader::String:
+ handleString(reader);
+ break;
+ case QCborStreamReader::Array:
+ case QCborStreamReader::Map:
+ reader.enterContainer();
+ while (reader.lastError() == QCborError::NoError)
+ handleStream(reader);
+ if (reader.lastError() == QCborError::NoError)
+ reader.leaveContainer();
+ }
+ }
+//! [24]
+
+//! [25]
+ QVariantList populateFromCbor(QCborStreamReader &reader)
+ {
+ QVariantList list;
+ if (reader.isLengthKnown())
+ list.reserve(reader.length());
+
+ reader.enterContainer();
+ while (reader.lastError() == QCborError::NoError && reader.hasNext())
+ list.append(readOneElement(reader));
+ if (reader.lastError() == QCborError::NoError)
+ reader.leaveContainer();
+ }
+//! [25]
+
+//! [26]
+ QVariantMap populateFromCbor(QCborStreamReader &reader)
+ {
+ QVariantMap map;
+ if (reader.isLengthKnown())
+ map.reserve(reader.length());
+
+ reader.enterContainer();
+ while (reader.lastError() == QCborError::NoError && reader.hasNext()) {
+ QString key = readElementAsString(reader);
+ map.insert(key, readOneElement(reader));
+ }
+ if (reader.lastError() == QCborError::NoError)
+ reader.leaveContainer();
+ }
+//! [26]
+
+//! [27]
+ QString decodeString(QCborStreamReader &reader)
+ {
+ QString result;
+ auto r = reader.readString();
+ while (r.code == QCborStreamReader::Ok) {
+ result += r.data;
+ r = reader.readString();
+ }
+
+ if (r.code == QCborStreamReader::Error) {
+ // handle error condition
+ result.clear();
+ }
+ return result;
+ }
+//! [27]
+
+//! [28]
+ QBytearray decodeBytearray(QCborStreamReader &reader)
+ {
+ QBytearray result;
+ auto r = reader.readBytearray();
+ while (r.code == QCborStreamReader::Ok) {
+ result += r.data;
+ r = reader.readByteArray();
+ }
+
+ if (r.code == QCborStreamReader::Error) {
+ // handle error condition
+ result.clear();
+ }
+ return result;
+ }
+//! [28]
+
+//! [29]
+ QCborStreamReader<qsizetype> result;
+ do {
+ qsizetype size = reader.currentStringChunkSize();
+ qsizetype oldsize = buffer.size();
+ buffer.resize(oldsize + size);
+ result = reader.readStringChunk(buffer.data() + oldsize, size);
+ } while (result.status() == QCborStreamReader::Ok);
+//! [29]
diff --git a/src/corelib/doc/snippets/code/src_corelib_serialization_qcborvalue.cpp b/src/corelib/doc/snippets/code/src_corelib_serialization_qcborvalue.cpp
new file mode 100644
index 0000000000..5406536cfe
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_serialization_qcborvalue.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+//! [0]
+ QCborValue(uuid) == QCborValue(QCborKnownTags::Uuid, uuid.toRfc4122());
+//! [0]
+
+//! [1]
+ QCborValue value(QCborSimpleType(12));
+//! [1]
+
+//! [2]
+ value.isSimpleType(QCborSimpleType(12));
+//! [2]
+
+//! [3]
+ QCborValue(QUrl("https://example.com")) == QCborValue(QCborKnownTags::Url, "https://example.com");
+//! [3]
+
+//! [4]
+ value.toMap().value(key);
+//! [4]
+
+//! [5]
+ value.toMap().value(key);
+//! [5]
+
+//! [6]
+ if (reader.isTag() && reader.toTag() == QCborKnownTags::Signature)
+ reader.next();
+
+ QCborValue contents = QCborValue::fromCbor(reader);
+//! [6]
diff --git a/src/corelib/doc/snippets/code/src_corelib_serialization_qdatastream.cpp b/src/corelib/doc/snippets/code/src_corelib_serialization_qdatastream.cpp
new file mode 100644
index 0000000000..cfcc2f8f94
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_serialization_qdatastream.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+//! [0]
+ QDataStream &operator<<(QDataStream &, const QXxx &);
+ QDataStream &operator>>(QDataStream &, QXxx &);
+//! [0]
+
+//! [1]
+ QDataStream & operator<< (QDataStream& stream, const QImage& image);
+ QDataStream & operator>> (QDataStream& stream, QImage& image);
+//! [1]
diff --git a/src/corelib/doc/snippets/code/src_corelib_serialization_qjsondocument.cpp b/src/corelib/doc/snippets/code/src_corelib_serialization_qjsondocument.cpp
new file mode 100644
index 0000000000..1fe328c0a0
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_serialization_qjsondocument.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+//! [0]
+ {
+ "Array": [
+ true,
+ 999,
+ "string"
+ ],
+ "Key": "Value",
+ "null": null
+ }
+//! [0]
+
+//! [1]
+ {"Array":[true,999,"string"],"Key":"Value","null":null}
+//! [1]
diff --git a/src/corelib/doc/snippets/code/src_corelib_thread_qsemaphore.cpp b/src/corelib/doc/snippets/code/src_corelib_thread_qsemaphore.cpp
index 2081e4fdd0..52105bce0b 100644
--- a/src/corelib/doc/snippets/code/src_corelib_thread_qsemaphore.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_thread_qsemaphore.cpp
@@ -81,3 +81,32 @@ QSemaphore sem(5); // sem.available() == 5
sem.tryAcquire(250, 1000); // sem.available() == 5, waits 1000 milliseconds and returns false
sem.tryAcquire(3, 30000); // sem.available() == 2, returns true without waiting
//! [3]
+
+//! [4]
+// ... do something that may throw or return early
+sem.release();
+//! [4]
+
+//! [5]
+const QSemaphoreReleaser releaser(sem);
+// ... do something that may throw or early return
+// implicitly calls sem.release() here and at every other return in between
+//! [5]
+
+//! [6]
+{ // some scope
+ QSemaphoreReleaser releaser; // does nothing
+ // ...
+ if (someCondition) {
+ releaser = QSemaphoreReleaser(sem);
+ // ...
+ }
+ // ...
+} // conditionally calls sem.release(), depending on someCondition
+//! [6]
+
+//! [7]
+releaser.cancel(); // avoid releasing old semaphore()
+releaser = QSemaphoreReleaser(sem, 42);
+// now will call sem.release(42) when 'releaser' is destroyed
+//! [7]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp
index bd7cdaa681..32fccbefbf 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp
@@ -470,6 +470,33 @@ ba4.size(); // Returns 6.
ba4.constData(); // Returns "ca\0r\0t" without terminating \0.
//! [48]
+//! [49]
+QByteArray ba("ab");
+ba.repeated(4); // returns "abababab"
+//! [49]
+
+//! [50]
+QByteArray macAddress = QByteArray::fromHex("123456abcdef");
+macAddress.toHex(':'); // returns "12:34:56:ab:cd:ef"
+macAddress.toHex(0); // returns "123456abcdef"
+//! [50]
+
+//! [51]
+QByteArray text = QByteArray::fromPercentEncoding("Qt%20is%20great%33");
+text.data(); // returns "Qt is great!"
+//! [51]
+
+//! [52]
+QByteArray text = "{a fishy string?}";
+QByteArray ba = text.toPercentEncoding("{}", "s");
+qDebug(ba.constData());
+// prints "{a fi%73hy %73tring%3F}"
+//! [52]
+
+//! [53]
+QByteArray ba = QByteArrayLiteral("byte array contents");
+//! [53]
+
}
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qbytearraymatcher.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qbytearraymatcher.cpp
new file mode 100644
index 0000000000..9cf94f0494
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qbytearraymatcher.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+//! [0]
+static const auto matcher = qMakeStaticByteArrayMatcher("needle");
+//! [0]
+
+//! [1]
+static const auto matcher = qMakeStaticByteArrayMatcher("needle");
+//! [1]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qcontiguouscache.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qcontiguouscache.cpp
new file mode 100644
index 0000000000..84780374e9
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qcontiguouscache.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+//! [0]
+MyRecord record(int row) const
+{
+ Q_ASSERT(row >= 0 && row < count());
+
+ while (row > cache.lastIndex())
+ cache.append(slowFetchRecord(cache.lastIndex()+1));
+ while (row < cache.firstIndex())
+ cache.prepend(slowFetchRecord(cache.firstIndex()-1));
+
+ return cache.at(row);
+}
+//! [0]
+
+//! [1]
+QContiguousCache<int> cache(10);
+cache.insert(INT_MAX, 1); // cache contains one value and has valid indexes, INT_MAX to INT_MAX
+cache.append(2); // cache contains two values but does not have valid indexes.
+cache.normalizeIndexes(); // cache has two values, 1 and 2. New first index will be in the range of 0 to capacity().
+//! [1]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp
index c7df6f6090..a3d2dd7f9e 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp
@@ -350,3 +350,23 @@ inline uint qHash(const std::unordered_set<int> &key, uint seed = 0)
return qHashRangeCommutative(key.begin(), key.end(), seed);
}
//! [qhashrangecommutative]
+
+//! [29]
+qHash(qMakePair(key.first, key.second), seed);
+//! [29]
+
+//! [30]
+{0, 1, 2}
+//! [30]
+
+//! [31]
+{1, 2, 0}
+//! [31]
+
+//! [32]
+uint qHash(K key);
+uint qHash(const K &key);
+
+uint qHash(K key, uint seed);
+uint qHash(const K &key, uint seed);
+//! [32]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp
index cc3f689710..0e746cd6e6 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp
@@ -146,7 +146,7 @@ list.move(1, 4);
//! [12]
QList<QString> list;
list << "A" << "B" << "C" << "D" << "E" << "F";
-list.swap(1, 4);
+list.swapItemsAt(1, 4);
// list: ["A", "E", "C", "D", "B", "F"]
//! [12]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qrect.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qrect.cpp
index 4bdaa4d657..a19dc086ac 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qrect.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qrect.cpp
@@ -58,3 +58,13 @@ QRect r2(QPoint(100, 200), QSize(11, 16));
QRectF r1(100.0, 200.1, 11.2, 16.3);
QRectF r2(QPointF(100.0, 200.1), QSizeF(11.2, 16.3));
//! [1]
+
+//! [2]
+QRect r = {15, 51, 42, 24};
+r = r.transposed(); // r == {15, 51, 24, 42}
+//! [2]
+
+//! [3]
+QRectF r = {1.5, 5.1, 4.2, 2.4};
+r = r.transposed(); // r == {1.5, 5.1, 2.4, 4.2}
+//! [3]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qregularexpression.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qregularexpression.cpp
index b5d8320bce..afdd9c3d25 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qregularexpression.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qregularexpression.cpp
@@ -360,4 +360,12 @@ QString wildcard = QRegularExpression::wildcardToRegularExpression("*.jpeg");
//! [31]
}
+//! [32]
+ (?<day>\d\d)-(?<month>\d\d)-(?<year>\d\d\d\d) (\w+) (?<name>\w+)
+//! [32]
+
+//! [33]
+ ("", "day", "month", "year", "", "name")
+//! [33]
+
}
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qscopeguard.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qscopeguard.cpp
index c8c5f694c6..2fa4f88011 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qscopeguard.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qscopeguard.cpp
@@ -57,7 +57,7 @@ void myComplexCodeWithMultipleReturnPoints(int v)
if (v == -1)
return;
- int v2 = code_that_might_through_exceptions();
+ int v2 = code_that_might_throw_exceptions();
if (v2 == -1)
return;
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qshareddata.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qshareddata.cpp
new file mode 100644
index 0000000000..88c8ae4151
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qshareddata.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+//! [0]
+ class EmployeeData;
+//! [0]
+
+//! [1]
+ template<>
+ EmployeeData *QSharedDataPointer<EmployeeData>::clone()
+ {
+ return d->clone();
+ }
+//! [1]
+
+//! [2]
+ QExplicitlySharedDataPointer<Base> base(new Base);
+ QExplicitlySharedDataPointer<Derived> derived(base); // !!! DANGER !!!
+//! [2]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qsharedpointer.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qsharedpointer.cpp
new file mode 100644
index 0000000000..e2979fa7b4
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qsharedpointer.cpp
@@ -0,0 +1,157 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+//! [0]
+ class Y: public QEnableSharedFromThis<Y>
+ {
+ public:
+ QSharedPointer<Y> f()
+ {
+ return sharedFromThis();
+ }
+ };
+
+ int main()
+ {
+ QSharedPointer<Y> p(new Y());
+ QSharedPointer<Y> y = p->f();
+ Q_ASSERT(p == y); // p and q must share ownership
+ }
+//! [0]
+
+//! [1]
+ class ScriptInterface : public QObject
+ {
+ Q_OBJECT
+
+ // ...
+
+ public slots:
+ void slotCalledByScript(Y *managedBySharedPointer)
+ {
+ QSharedPointer<Y> yPtr = managedBySharedPointer->sharedFromThis();
+ // Some other code unrelated to scripts that expects a QSharedPointer<Y> ...
+ }
+ };
+//! [1]
+
+//! [2]
+ static void doDeleteLater(MyObject *obj)
+ {
+ obj->deleteLater();
+ }
+
+ void otherFunction()
+ {
+ QSharedPointer<MyObject> obj =
+ QSharedPointer<MyObject>(new MyObject, doDeleteLater);
+
+ // continue using obj
+ obj.clear(); // calls obj->deleteLater();
+ }
+//! [2]
+
+//! [3]
+ QSharedPointer<MyObject> obj =
+ QSharedPointer<MyObject>(new MyObject, &QObject::deleteLater);
+//! [3]
+
+//! [4]
+ if (sharedptr) { ... }
+//! [4]
+
+//! [5]
+ if (!sharedptr) { ... }
+//! [5]
+
+//! [6]
+ QSharedPointer<T> other(t); this->swap(other);
+//! [6]
+
+//! [7]
+ QSharedPointer<T> other(t, deleter); this->swap(other);
+//! [7]
+
+//! [8]
+ if (weakref) { ... }
+//! [8]
+
+//! [9]
+ if (!weakref) { ... }
+//! [9]
+
+//! [10]
+ qDebug("Tracking %p", weakref.data());
+//! [10]
+
+//! [11]
+ // this pointer cannot be used in another thread
+ // so other threads cannot delete it
+ QWeakPointer<int> weakref = obtainReference();
+
+ Object *obj = weakref.data();
+ if (obj) {
+ // if the pointer wasn't deleted yet, we know it can't get
+ // deleted by our own code here nor the functions we call
+ otherFunction(obj);
+ }
+//! [11]
+
+//! [12]
+ QWeakPointer<int> weakref;
+
+ // ...
+
+ QSharedPointer<int> strong = weakref.toStrongRef();
+ if (strong)
+ qDebug() << "The value is:" << *strong;
+ else
+ qDebug() << "The value has already been deleted";
+//! [12]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qstring.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qstring.cpp
index 9b3e89e5c4..4e79d1e27a 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qstring.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qstring.cpp
@@ -102,3 +102,21 @@ QString plain = "#include <QtCore>"
QString html = plain.toHtmlEscaped();
// html == "#include &lt;QtCore&gt;"
//! [7]
+
+//! [8]
+QString str("ab");
+str.repeated(4); // returns "abababab"
+//! [8]
+
+//! [9]
+// hasAttribute takes a QString argument
+if (node.hasAttribute("http-contents-length")) //...
+//! [9]
+
+//! [10]
+if (node.hasAttribute(QStringLiteral(u"http-contents-length"))) //...
+//! [10]
+
+//! [11]
+if (attribute.name() == QLatin1String("http-contents-length")) //...
+//! [11]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qstringview.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qstringview.cpp
new file mode 100644
index 0000000000..fc426e1977
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qstringview.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+//! [0]
+ void myfun1(QStringView sv); // preferred
+ void myfun2(const QStringView &sv); // compiles and works, but slower
+//! [0]
+
+//! [1]
+ void fun(QChar ch) { fun(QStringView(&ch, 1)); }
+//! [1]
+
+//! [2]
+ auto sv = QStringView(array, std::size(array)); // using C++17 std::size()
+//! [2]
diff --git a/src/corelib/doc/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp b/src/corelib/doc/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp
index d89e28836f..c1af521c03 100644
--- a/src/corelib/doc/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp
+++ b/src/corelib/doc/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the QtGui module of the Qt Toolkit.
+** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
diff --git a/src/corelib/doc/snippets/hellotrmain.cpp b/src/corelib/doc/snippets/hellotrmain.cpp
index 7e09c58f4f..2fab919a47 100644
--- a/src/corelib/doc/snippets/hellotrmain.cpp
+++ b/src/corelib/doc/snippets/hellotrmain.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
diff --git a/src/corelib/doc/snippets/qbytearraylist/main.cpp b/src/corelib/doc/snippets/qbytearraylist/main.cpp
index 8a861eca4a..fd52ef945b 100644
--- a/src/corelib/doc/snippets/qbytearraylist/main.cpp
+++ b/src/corelib/doc/snippets/qbytearraylist/main.cpp
@@ -3,9 +3,9 @@
** Copyright (C) 2014 by Southwest Research Institute (R)
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the QtCore module of the Qt Toolkit.
+** This file is part of the documentation of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL$
+** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -14,24 +14,35 @@
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
**
diff --git a/src/corelib/doc/snippets/qelapsedtimer/main.cpp b/src/corelib/doc/snippets/qelapsedtimer/main.cpp
index add6ad0169..408c4eab07 100644
--- a/src/corelib/doc/snippets/qelapsedtimer/main.cpp
+++ b/src/corelib/doc/snippets/qelapsedtimer/main.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the QtNetwork module of the Qt Toolkit.
+** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
diff --git a/src/corelib/doc/snippets/qloggingcategory/main.cpp b/src/corelib/doc/snippets/qloggingcategory/main.cpp
index 73df3c2d2f..f5c47b2ae8 100644
--- a/src/corelib/doc/snippets/qloggingcategory/main.cpp
+++ b/src/corelib/doc/snippets/qloggingcategory/main.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
diff --git a/src/corelib/doc/snippets/resource-system/mainwindow.cpp b/src/corelib/doc/snippets/resource-system/mainwindow.cpp
index 6fcf52e588..86e93aaa62 100644
--- a/src/corelib/doc/snippets/resource-system/mainwindow.cpp
+++ b/src/corelib/doc/snippets/resource-system/mainwindow.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
@@ -338,11 +338,11 @@ void MainWindow::loadFile(const QString &fileName)
QTextStream in(&file);
#ifndef QT_NO_CURSOR
- QApplication::setOverrideCursor(Qt::WaitCursor);
+ QGuiApplication::setOverrideCursor(Qt::WaitCursor);
#endif
textEdit->setPlainText(in.readAll());
#ifndef QT_NO_CURSOR
- QApplication::restoreOverrideCursor();
+ QGuiApplication::restoreOverrideCursor();
#endif
setCurrentFile(fileName);
@@ -365,11 +365,11 @@ bool MainWindow::saveFile(const QString &fileName)
QTextStream out(&file);
#ifndef QT_NO_CURSOR
- QApplication::setOverrideCursor(Qt::WaitCursor);
+ QGuiApplication::setOverrideCursor(Qt::WaitCursor);
#endif
out << textEdit->toPlainText();
#ifndef QT_NO_CURSOR
- QApplication::restoreOverrideCursor();
+ QGuiApplication::restoreOverrideCursor();
#endif
setCurrentFile(fileName);
diff --git a/src/corelib/doc/snippets/signalsandslots/lcdnumber.h b/src/corelib/doc/snippets/signalsandslots/lcdnumber.h
index fbd31b08cf..b311586e8f 100644
--- a/src/corelib/doc/snippets/signalsandslots/lcdnumber.h
+++ b/src/corelib/doc/snippets/signalsandslots/lcdnumber.h
@@ -69,7 +69,7 @@ class LcdNumber : public QFrame
//! [6]
public:
//! [6] //! [7]
- LcdNumber(QWidget *parent = 0);
+ LcdNumber(QWidget *parent = nullptr);
//! [7]
//! [8]
diff --git a/src/corelib/doc/snippets/timers/analogclock.cpp b/src/corelib/doc/snippets/timers/analogclock.cpp
index 0dc2fbc708..4e1957a450 100644
--- a/src/corelib/doc/snippets/timers/analogclock.cpp
+++ b/src/corelib/doc/snippets/timers/analogclock.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
diff --git a/src/corelib/doc/src/containers.qdoc b/src/corelib/doc/src/containers.qdoc
index a1c32bb007..e6c95129db 100644
--- a/src/corelib/doc/src/containers.qdoc
+++ b/src/corelib/doc/src/containers.qdoc
@@ -171,8 +171,9 @@
The values stored in the various containers can be of any
\e{assignable data type}. To qualify, a type must provide a
- default constructor, a copy constructor, and an assignment
- operator. This covers most data types you are likely to want to
+ copy constructor, and an assignment operator. For some
+ operations a default constructor is also required. This
+ covers most data types you are likely to want to
store in a container, including basic types such as \c int and \c
double, pointer types, and Qt data types such as QString, QDate,
and QTime, but it doesn't cover QObject or any QObject subclass
diff --git a/src/corelib/doc/src/datastreamformat.qdoc b/src/corelib/doc/src/datastreamformat.qdoc
index 73ca51974d..d6b60f10ce 100644
--- a/src/corelib/doc/src/datastreamformat.qdoc
+++ b/src/corelib/doc/src/datastreamformat.qdoc
@@ -28,357 +28,71 @@
/*!
\page datastreamformat.html
\title Serializing Qt Data Types
- \brief Representations of data types that can be serialized by QDataStream.
+ \brief List of data types that can be serialized by QDataStream.
- The \l QDataStream allows you to serialize some of the Qt data types.
- The table below lists the data types that QDataStream can serialize
- and how they are represented. The format described below is
- \l{QDataStream::setVersion()}{version 13}.
+ The \l QDataStream class allows you to serialize the Qt data types
+ listed in this section as of \l{QDataStream::setVersion()}{version 18}.
It is always best to cast integers to a Qt integer type, such as
- qint16 or quint32, when reading and writing. This ensures that
+ \l{qint16} or \l{quint32}, when reading and writing. This ensures that
you always know exactly what size integers you are reading and
writing, no matter what the underlying platform and architecture
the application happens to be running on.
- \table
- \row \li bool
- \li \list
- \li boolean
- \endlist
- \row \li qint8
- \li \list
- \li signed byte
- \endlist
- \row \li qint16
- \li \list
- \li signed 16-bit integer
- \endlist
- \row \li qint32
- \li \list
- \li signed 32-bit integer
- \endlist
- \row \li qint64
- \li \list
- \li signed 64-bit integer
- \endlist
- \row \li quint8
- \li \list
- \li unsigned byte
- \endlist
- \row \li quint16
- \li \list
- \li unsigned 16-bit integer
- \endlist
- \row \li quint32
- \li \list
- \li unsigned 32-bit integer
- \endlist
- \row \li quint64
- \li \list
- \li unsigned 64-bit integer
- \endlist
- \row \li \c float
- \li \list
- \li 32-bit floating point number using the standard IEEE 754 format
- \endlist
- \row \li \c double
- \li \list
- \li 64-bit floating point number using the standard IEEE 754 format
- \endlist
- \row \li \c {const char *}
- \li \list
- \li The string length (quint32)
- \li The string bytes, excluding the terminating 0
- \endlist
- \row \li QBitArray
- \li \list
- \li The array size (quint32)
- \li The array bits, i.e. (size + 7)/8 bytes
- \endlist
- \row \li QBrush
- \li \list
- \li The brush style (quint8)
- \li The brush color (QColor)
- \li If style is CustomPattern, the brush pixmap (QPixmap)
- \endlist
- \row \li QByteArray
- \li \list
- \li If the byte array is null: 0xFFFFFFFF (quint32)
- \li Otherwise: the array size (quint32) followed by the array bytes, i.e. size bytes
- \endlist
- \row \li \l QColor
- \li \list
- \li Color spec (qint8)
- \li Alpha value (quint16)
- \li Red value (quint16)
- \li Green value (quint16)
- \li Blue value (quint16)
- \li Pad value (quint16)
- \endlist
- \row \li QCursor
- \li \list
- \li Shape ID (qint16)
- \li If shape is BitmapCursor: The bitmap (QPixmap), mask (QPixmap), and hot spot (QPoint)
- \endlist
- \row \li QDate
- \li \list
- \li Julian day (quint32)
- \endlist
- \row \li QDateTime
- \li \list
- \li Date (QDate)
- \li Time (QTime)
- \li The \l{Qt::TimeSpec}{time spec}
- offsetFromUtc (qint32) if Qt::TimeSpec is offsetFromUtc
- TimeZone(QTimeZone) if Qt::TimeSpec is TimeZone
- \endlist
- \row \li QEasingCurve
- \li \list
- \li type (quint8)
- \li func (quint64)
- \li hasConfig (bool)
- \li If hasConfig is true then these fields follow:
- \li list
- \li period (double)
- \li amplitude (double)
- \li overshoot (double)
- \endlist
- \row \li QFont
- \li \list
- \li The family (QString)
- \li The style name (QString)
- \li The point size (double)
- \li The pixel size (qint32)
- \li The style hint (quint8)
- \li The style strategy (quint16)
- \li The char set (quint8)
- \li The weight (quint8)
- \li The font bits (quint8)
- \li The font stretch (quint16)
- \li The extended font bits (quint8)
- \li The letter spacing (double)
- \li The word spacing (double)
- \li The hinting preference (quint8)
- \endlist
- \row \li QHash<Key, T>
- \li \list
- \li The number of items (quint32)
- \li For all items, the key (Key) and value (T)
- \endlist
- \row \li QIcon
- \li \list
- \li The number of pixmap entries (quint32)
- \li For all pixmap entries:
- \list
- \li The pixmap (QPixmap)
- \li The file name (QString)
- \li The pixmap size (QSize)
- \li The \l{QIcon::Mode}{mode} (quint32)
- \li The \l{QIcon::State}{state} (quint32)
- \endlist
- \endlist
- \row \li QImage
- \li \list
- \li If the image is null a "null image" marker is saved;
- otherwise the image is saved in PNG or BMP format (depending
- on the stream version). If you want control of the format,
- stream the image into a QBuffer (using QImageIOHandler/QImageIOPlugin) and stream
- that.
- \endlist
- \row \li QKeySequence
- \li \list
- \li A QList<int>, where each integer is a key in the key sequence
- \endlist
- \row \li QLinkedList<T>
- \li \list
- \li The number of items (quint32)
- \li The items (T)
- \endlist
- \row \li QList<T>
- \li \list
- \li The number of items (quint32)
- \li The items (T)
- \endlist
- \row \li QMap<Key, T>
- \li \list
- \li The number of items (quint32)
- \li For all items, the key (Key) and value (T)
- \endlist
- \row \li QMargins
- \li \list
- \li left (int)
- \li top (int)
- \li right (int)
- \li bottom (int)
- \endlist
- \row \li QMatrix
- \li \list
- \li m11 (double)
- \li m12 (double)
- \li m21 (double)
- \li m22 (double)
- \li dx (double)
- \li dy (double)
- \endlist
- \row \li QMatrix4x4
- \li \list
- \li m11 (float)
- \li m12 (float)
- \li m13 (float)
- \li m14 (float)
- \li m21 (float)
- \li m22 (float)
- \li m23 (float)
- \li m24 (float)
- \li m31 (float)
- \li m32 (float)
- \li m33 (float)
- \li m34 (float)
- \li m41 (float)
- \li m42 (float)
- \li m43 (float)
- \li m44 (float)
- \endlist
- \row \li QPair<T1, T2>
- \li \list
- \li first (T1)
- \li second (T2)
- \endlist
- \row \li QPalette
- \li The disabled, active, and inactive color groups, each of which consists
- of the following:
- \list
- \li foreground (QBrush)
- \li button (QBrush)
- \li light (QBrush)
- \li midlight (QBrush)
- \li dark (QBrush)
- \li mid (QBrush)
- \li text (QBrush)
- \li brightText (QBrush)
- \li buttonText (QBrush)
- \li base (QBrush)
- \li background (QBrush)
- \li shadow (QBrush)
- \li highlight (QBrush)
- \li highlightedText (QBrush)
- \li link (QBrush)
- \li linkVisited (QBrush)
- \endlist
- \row \li QPen
- \li \list
- \li The pen styles (quint8)
- \li The pen width (quint16)
- \li The pen color (QColor)
- \endlist
- \row \li QPicture
- \li \list
- \li The size of the picture data (quint32)
- \li The raw bytes of picture data (char)
- \endlist
- \row \li QPixmap
- \li \list
- \li Save it as a PNG image.
- \endlist
- \row \li QPoint
- \li \list
- \li The x coordinate (qint32)
- \li The y coordinate (qint32)
- \endlist
- \row \li QQuaternion
- \li \list
- \li The scalar component (float)
- \li The x coordinate (float)
- \li The y coordinate (float)
- \li The z coordinate (float)
- \endlist
- \row \li QRect
- \li \list
- \li left (qint32)
- \li top (qint32)
- \li right (qint32)
- \li bottom (qint32)
- \endlist
- \row \li QRegExp
- \li \list
- \li The regexp pattern (QString)
- \li Case sensitivity (quint8)
- \li Regular expression syntax (quint8)
- \li Minimal matching (quint8)
- \endlist
- \row \li QRegularExpression
- \li \list
- \li The regular expression pattern (QString)
- \li The pattern options (quint32)
- \endlist
- \row \li QRegion
- \li \list
- \li The size of the data, i.e. 8 + 16 * (number of rectangles) (quint32)
- \li 10 (qint32)
- \li The number of rectangles (quint32)
- \li The rectangles in sequential order (QRect)
- \endlist
- \row \li QSize
- \li \list
- \li width (qint32)
- \li height (qint32)
- \endlist
- \row \li QString
- \li \list
- \li If the string is null: 0xFFFFFFFF (quint32)
- \li Otherwise: The string length in bytes (quint32) followed by the data in UTF-16
- \endlist
- \row \li QTime
- \li \list
- \li Milliseconds since midnight (quint32)
- \endlist
- \row \li QTransform
- \li \list
- \li m11 (double)
- \li m12 (double)
- \li m13 (double)
- \li m21 (double)
- \li m22 (double)
- \li m23 (double)
- \li m31 (double)
- \li m32 (double)
- \li m33 (double)
- \endlist
- \row \li QUrl
- \li \list
- \li Holds an URL (QString)
- \endlist
- \row \li QVariant
- \li \list
- \li The type of the data (quint32)
- \li The null flag (qint8)
- \li The data of the specified type
- \endlist
- \row \li QVector2D
- \li \list
- \li the x coordinate (float)
- \li the y coordinate (float)
- \endlist
- \row \li QVector3D
- \li \list
- \li the x coordinate (float)
- \li the y coordinate (float)
- \li the z coordinate (float)
- \endlist
- \row \li QVector4D
- \li \list
- \li the x coordinate (float)
- \li the y coordinate (float)
- \li the z coordinate (float)
- \li the w coordinate (float)
- \endlist
- \row \li QVector<T>
- \li \list
- \li The number of items (quint32)
- \li The items (T)
- \endlist
- \endtable
+ \list
+ \li bool
+ \li \l{qint8}
+ \li \l{qint16}
+ \li \l{qint32}
+ \li \l{qint64}
+ \li \l{quint8}
+ \li \l{quint16}
+ \li \l{quint32}
+ \li \l{quint64}
+ \li \c float
+ \li \c double
+ \li \c {const char *}
+ \li QBitArray
+ \li QBrush
+ \li QByteArray
+ \li QColor
+ \li QCursor
+ \li QDate
+ \li QDateTime
+ \li QEasingCurve
+ \li QFont
+ \li QGenericMatrix
+ \li QHash<Key, T>
+ \li QIcon
+ \li QImage
+ \li QKeySequence
+ \li QLinkedList<T>
+ \li QList<T>
+ \li QMap<Key, T>
+ \li QMargins
+ \li QMatrix4x4
+ \li QPair<T1, T2>
+ \li QPalette
+ \li QPen
+ \li QPicture
+ \li QPixmap
+ \li QPoint
+ \li QQuaternion
+ \li QRect
+ \li QRegExp
+ \li QRegularExpression
+ \li QRegion
+ \li QSize
+ \li QString
+ \li QTime
+ \li QTransform
+ \li QUrl
+ \li QVariant
+ \li QVector2D
+ \li QVector3D
+ \li QVector4D
+ \li QVector<T>
+ \endlist
\sa {JSON Support in Qt}
*/
diff --git a/src/corelib/doc/src/external-resources.qdoc b/src/corelib/doc/src/external-resources.qdoc
index f7c9dbb365..f16a21d521 100644
--- a/src/corelib/doc/src/external-resources.qdoc
+++ b/src/corelib/doc/src/external-resources.qdoc
@@ -32,13 +32,13 @@
*/
/*!
- \externalpage http://www.geocities.com/Athens/5180/tsciiset.html
- \title http://www.geocities.com/Athens/5180/tsciiset.html
+ \externalpage https://en.wikipedia.org/wiki/Tamil_Script_Code_for_Information_Interchange
+ \title Tamil Script Code
*/
/*!
- \externalpage http://www.tamil.net/tscii/
- \title http://www.tamil.net/tscii/
+ \externalpage http://home.infitt.org
+ \title Information Technology in Tamil
*/
/*!
diff --git a/src/corelib/doc/src/objectmodel/metaobjects.qdoc b/src/corelib/doc/src/objectmodel/metaobjects.qdoc
index 5b3d8f9863..53b34fe120 100644
--- a/src/corelib/doc/src/objectmodel/metaobjects.qdoc
+++ b/src/corelib/doc/src/objectmodel/metaobjects.qdoc
@@ -86,7 +86,7 @@
that it doesn't require RTTI support and it works across dynamic
library boundaries. It attempts to cast its argument to the pointer
type specified in angle-brackets, returning a non-zero pointer if the
- object is of the correct type (determined at run-time), or 0
+ object is of the correct type (determined at run-time), or \nullptr
if the object's type is incompatible.
For example, let's assume \c MyWidget inherits from QWidget and
diff --git a/src/corelib/doc/src/objectmodel/signalsandslots.qdoc b/src/corelib/doc/src/objectmodel/signalsandslots.qdoc
index fcf091458a..85fe4df2ce 100644
--- a/src/corelib/doc/src/objectmodel/signalsandslots.qdoc
+++ b/src/corelib/doc/src/objectmodel/signalsandslots.qdoc
@@ -330,7 +330,7 @@
arguments can have default values. Consider QObject::destroyed():
\code
- void destroyed(QObject* = 0);
+ void destroyed(QObject* = nullptr);
\endcode
When a QObject is deleted, it emits this QObject::destroyed()
@@ -339,7 +339,7 @@
A suitable slot signature might be:
\code
- void objectDestroyed(QObject* obj = 0);
+ void objectDestroyed(QObject* obj = nullptr);
\endcode
To connect the signal to the slot, we use QObject::connect().
diff --git a/src/corelib/doc/src/resource-system.qdoc b/src/corelib/doc/src/resource-system.qdoc
index 9b6b613f79..69ec5e556b 100644
--- a/src/corelib/doc/src/resource-system.qdoc
+++ b/src/corelib/doc/src/resource-system.qdoc
@@ -100,6 +100,9 @@
See the QLocale documentation for a description of the format to use
for locale strings.
+ See QFileSelector for an additional mechanism to select locale-specific
+ resources, in addition to the ability to select OS-specific and other
+ features.
\section2 External Binary Resources
@@ -143,24 +146,70 @@
\section1 Compression
- Resources are compressed by default (in the \c ZIP format). It is
- possible to turn off compression. This can be useful if your
- resources already contain a compressed format, such as \c .png
- files. You do this by giving the \c {-no-compress} command line
- argument.
+ \c rcc attempts to compress the content to optimize disk space usage in the
+ final binaries. By default, it will perform a heuristic check to determine
+ whether compressing is worth it and will store the content uncompressed if
+ it fails to sufficiently compress. To control the threshold, you can use
+ the \c {-threshold} option, which tells \c rcc the percentage of the
+ original file size that must be gained for it to store the file in
+ compressed form.
+
+ \code
+ rcc -threshold 25 myresources.qrc
+ \endcode
+
+ The default value is "70", indicating that the compressed file must be 70%
+ smaller than the original (no more than 30% of the original file size).
+
+ It is possible to turn off compression, if desired. This can be useful if
+ your resources already contain a compressed format, such as \c .png files,
+ and you do not want to incur the CPU cost at build time to confirm that it
+ can't be compressed. Another reason is if disk usage is not a problem and
+ the application would prefer to keep the content as clean memory pages at
+ runtime. You do this by giving the \c {-no-compress} command line argument.
\code
rcc -no-compress myresources.qrc
\endcode
- \c rcc also gives you some control over the compression. You can
- specify the compression level and the threshold level to consider
- while compressing files, for example:
+ \c rcc also gives you some control over the compression level and
+ compression algorithm, for example:
\code
- rcc -compress 2 -threshold 3 myresources.qrc
+ rcc -compress 2 -compress-algo zlib myresources.qrc
\endcode
+ \c rcc supports the following compression algorithms and compression
+ levels:
+
+ \list
+ \li \c{best}: use the best algorithm among the ones below, at its highest
+ compression level, to achieve the most compression at the expense of
+ using a lot of CPU time during compilation. This value is useful in the
+ XML file to indicate a file should be most compressed, regardless of
+ which algorithms \c rcc supports.
+
+ \li \c{zstd}: use the \l{Zstandard}{https://zstd.net} library to compress
+ contents. Valid compression levels range from 1 to 19, 1 is least
+ compression (least CPU time) and 19 is the most compression (most CPU
+ time). The default level is 14. A special value of 0 tells the \c{zstd}
+ library to choose an implementation-defined default.
+
+ \li \c{zlib}: use the \l{zlib}{https://zlib.net} library to compress
+ contents. Valid compression levels range from 1 to 9, with 1the least
+ compression (least CPU time) and 9 the most compression (most CPU time).
+ The special value 0 means "no compression" and should not be used. The
+ default is implementation-defined, but usually is level 6.
+
+ \li \c{none}: no compression. This is the same as the \c{-no-compress}
+ option.
+ \endlist
+
+ Support for both Zstandard and zlib are optional. If a given library was
+ not detected at compile time, attempting to pass \c {-compress-algo} for
+ that library will result in an error. The default compression algorithm is
+ \c zstd if it is enabled, \c zlib if not.
+
\section1 Using Resources in the Application
In the application, resource paths can be used in most places