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>
This commit is contained in:
Samuel Gaist 2019-10-19 08:53:45 +02:00
parent cffb88928c
commit c8aadc79fc
6 changed files with 42 additions and 0 deletions

View File

@ -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]

View File

@ -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,

View File

@ -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.

View File

@ -2014,6 +2014,8 @@ void **QListData::erase(void **xi)
\snippet code/src_corelib_tools_qlistdata.cpp 21
\include containers-range-constructor.qdocinc
\sa fromSet(), toVector(), QVector::toList()
*/
@ -2025,6 +2027,8 @@ void **QListData::erase(void **xi)
\snippet code/src_corelib_tools_qlistdata.cpp 22
\include containers-range-constructor.qdocinc
\sa toSet(), fromVector(), QVector::fromList()
*/
@ -2037,6 +2041,8 @@ void **QListData::erase(void **xi)
\snippet code/src_corelib_tools_qlistdata.cpp 23
\include containers-range-constructor.qdocinc
\sa fromVector(), toSet(), QSet::toList()
*/
@ -2050,6 +2056,8 @@ void **QListData::erase(void **xi)
\snippet code/src_corelib_tools_qlistdata.cpp 24
\include containers-range-constructor.qdocinc
\sa toVector(), fromSet(), QSet::fromList()
*/
@ -2062,6 +2070,8 @@ void **QListData::erase(void **xi)
\snippet code/src_corelib_tools_qlistdata.cpp 25
\include containers-range-constructor.qdocinc
\sa toStdList(), QVector::fromStdVector()
*/
@ -2072,6 +2082,8 @@ void **QListData::erase(void **xi)
\snippet code/src_corelib_tools_qlistdata.cpp 26
\include containers-range-constructor.qdocinc
\sa fromStdList(), QVector::toStdVector()
*/

View File

@ -1001,6 +1001,8 @@
\snippet code/doc_src_qset.cpp 13
\include containers-range-constructor.qdocinc
\sa fromList(), QList::fromSet()
*/
@ -1011,6 +1013,8 @@
This is the same as toList().
\include containers-range-constructor.qdocinc
\sa fromList(), QList::fromSet()
*/
@ -1026,6 +1030,8 @@
\snippet code/doc_src_qset.cpp 14
\include containers-range-constructor.qdocinc
\sa toList(), QList::toSet()
*/

View File

@ -1359,6 +1359,8 @@
\snippet code/src_corelib_tools_qvector.cpp 14
\include containers-range-constructor.qdocinc
\sa fromList(), QList::fromVector()
*/
@ -1370,6 +1372,8 @@
\snippet code/src_corelib_tools_qvector.cpp 15
\include containers-range-constructor.qdocinc
\sa toList(), QList::toVector()
*/
@ -1382,6 +1386,8 @@
\snippet code/src_corelib_tools_qvector.cpp 16
\include containers-range-constructor.qdocinc
\sa toStdVector(), QList::fromStdList()
*/
@ -1392,6 +1398,8 @@
\snippet code/src_corelib_tools_qvector.cpp 17
\include containers-range-constructor.qdocinc
\sa fromStdVector(), QList::toStdList()
*/