summaryrefslogtreecommitdiffstats
path: root/src/corelib/doc
diff options
context:
space:
mode:
authorSamuel Gaist <samuel.gaist@idiap.ch>2019-10-19 08:53:45 +0200
committerSamuel Gaist <samuel.gaist@idiap.ch>2019-10-24 23:10:21 +0200
commitc8aadc79fceac70ec18a3971d61c52930ef5f589 (patch)
tree94bd9f56c6917518009011e9608199c709e2c1c3 /src/corelib/doc
parentcffb88928cf945857a0983cac3e57f7b9d0befaa (diff)
QSet: Document to/from QVector transformation techniques
Change-Id: I2a2ff6332bd6e8ed3d4ba7b4765da0a94a06f133 Fixes: QTBUG-71067 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/corelib/doc')
-rw-r--r--src/corelib/doc/snippets/code/doc_src_containers.cpp8
-rw-r--r--src/corelib/doc/src/containers.qdoc6
-rw-r--r--src/corelib/doc/src/includes/containers-range-constructor.qdocinc2
3 files changed, 16 insertions, 0 deletions
diff --git a/src/corelib/doc/snippets/code/doc_src_containers.cpp b/src/corelib/doc/snippets/code/doc_src_containers.cpp
index 443f6b688c..84935580c9 100644
--- a/src/corelib/doc/snippets/code/doc_src_containers.cpp
+++ b/src/corelib/doc/snippets/code/doc_src_containers.cpp
@@ -312,3 +312,11 @@ int j = *i; // Undefined behavior!
but with QVector this is likely to crash.
*/
//! [24]
+
+//! [25]
+QVector<int> vector{1, 2, 3, 4, 4, 5};
+QSet<int> set(vector.begin(), vector.end());
+/*
+ Will generate a QSet containing 1, 2, 4, 5.
+*/
+//! [25]
diff --git a/src/corelib/doc/src/containers.qdoc b/src/corelib/doc/src/containers.qdoc
index 919533f651..d0bb251e81 100644
--- a/src/corelib/doc/src/containers.qdoc
+++ b/src/corelib/doc/src/containers.qdoc
@@ -66,6 +66,12 @@
Qt also offers a \l{foreach} keyword that make it very
easy to iterate over all the items stored in a container.
+ \note Since Qt 5.14, range constructors are available for most of the
+ container classes. QMultiMap is a notable exception. Their use is
+ encouraged in place of the various from/to methods. For example:
+
+ \snippet code/doc_src_containers.cpp 25
+
\section1 The Container Classes
Qt provides the following sequential containers: QList,
diff --git a/src/corelib/doc/src/includes/containers-range-constructor.qdocinc b/src/corelib/doc/src/includes/containers-range-constructor.qdocinc
new file mode 100644
index 0000000000..afb7e46b86
--- /dev/null
+++ b/src/corelib/doc/src/includes/containers-range-constructor.qdocinc
@@ -0,0 +1,2 @@
+ \note Since Qt 5.14, range constructors are available for Qt's generic
+ \l{container classes} and should be used in place of this method.