diff --git a/src/corelib/doc/snippets/code/doc_src_containers.cpp b/src/corelib/doc/snippets/code/doc_src_containers.cpp index 29d9b584d0d..680a099f68e 100644 --- a/src/corelib/doc/snippets/code/doc_src_containers.cpp +++ b/src/corelib/doc/snippets/code/doc_src_containers.cpp @@ -247,9 +247,9 @@ target_compile_definitions(my_app PRIVATE QT_NO_KEYWORDS) QString onlyLetters(const QString &in) { QString out; - for (int j = 0; j < in.size(); ++j) { - if (in[j].isLetter()) - out += in[j]; + for (qsizetype j = 0; j < in.size(); ++j) { + if (in.at(j).isLetter()) + out += in.at(j); } return out; } @@ -286,15 +286,15 @@ int j = *i; // Undefined behavior! //! [24] //! [25] -QList list { 1, 2, 3, 4, 4, 5 }; -QSet set(list.begin(), list.end()); +QList list = {1, 2, 3, 4, 4, 5}; +QSet set(list.cbegin(), list.cend()); /* Will generate a QSet containing 1, 2, 3, 4, 5. */ //! [25] //! [26] -QList list { 2, 3, 1 }; +QList list = {2, 3, 1}; std::sort(list.begin(), list.end()); /* diff --git a/src/corelib/doc/src/containers.qdoc b/src/corelib/doc/src/containers.qdoc index b5f4029fbe1..4a7d5dc1bb1 100644 --- a/src/corelib/doc/src/containers.qdoc +++ b/src/corelib/doc/src/containers.qdoc @@ -39,7 +39,8 @@ \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: + encouraged to replace of the various deprecated from/to methods of Qt 5. + For example: \snippet code/doc_src_containers.cpp 25 @@ -285,12 +286,10 @@ In the code snippets so far, we used the unary \c * operator to retrieve the item (of type QString) stored at a certain iterator - position, and we then called QString::toLower() on it. Most C++ - compilers also allow us to write \c{i->toLower()}, but some - don't. + position, and we then called QString::toLower() on it. - For read-only access, you can use const_iterator, \l{QList::constBegin}{constBegin()}, - and \l{QList::constEnd()}{constEnd()}. For example: + For read-only access, you can use const_iterator, \l{QList::cbegin}{cbegin()}, + and \l{QList::cend()}{cend()}. For example: \snippet code/doc_src_containers.cpp 12 @@ -384,7 +383,7 @@ \li Similar to std::queue, inherits from \l{QList}. \row \li \l{QSet} - \li Similar to std::set. Internally, \l{QSet} is implemented with a + \li Similar to std::unordered_set. Internally, \l{QSet} is implemented with a \l{QHash}. \row \li \l{QMap} @@ -394,10 +393,10 @@ \li Similar to std::multimap. \row \li \l{QHash} - \li Most similar to std::map. + \li Most similar to std::unordered_map. \row \li \l{QMultiHash} - \li Most similar to std::multimap. + \li Most similar to std::unordered_multimap. \endtable