diff options
author | Kai Koehne <kai.koehne@qt.io> | 2018-03-20 15:07:04 +0100 |
---|---|---|
committer | Kai Koehne <kai.koehne@qt.io> | 2018-04-23 06:27:40 +0000 |
commit | a69a3594e2c4122aef91c5511d5eeb78b7bfcb5c (patch) | |
tree | b99564d4854109119d4dda36eb9616006a344a9b /src/corelib/tools/qlist.cpp | |
parent | e555c03a4255bb4109a4b55d38561297ce8a2d2e (diff) |
Doc: Advocate use of std::initializer_list constructor in Q[String]List
We're relying on C++11 since a while, so lets not advertise creating
lists of strings with operator<<() anymore.
Change-Id: I14a3442ff852ac2c106d90c63504eb9ebb737609
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/corelib/tools/qlist.cpp')
-rw-r--r-- | src/corelib/tools/qlist.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp index 33835e3d28..17aba8035b 100644 --- a/src/corelib/tools/qlist.cpp +++ b/src/corelib/tools/qlist.cpp @@ -408,15 +408,20 @@ void **QListData::erase(void **xi) from strings. QList stores a list of items. The default constructor creates an - empty list. To insert items into the list, you can use - operator<<(): + empty list. You can use the initializer-list constructor to create + a list with elements: - \snippet code/src_corelib_tools_qlistdata.cpp 1 + \snippet code/src_corelib_tools_qlistdata.cpp 1a QList provides these basic functions to add, move, and remove items: insert(), replace(), removeAt(), move(), and swap(). In addition, it provides the following convenience functions: - append(), prepend(), removeFirst(), and removeLast(). + append(), \l{operator<<()}, \l{operator+=()}, prepend(), removeFirst(), + and removeLast(). + + \l{operator<<()} allows to conveniently add multiple elements to a list: + + \snippet code/src_corelib_tools_qlistdata.cpp 1b QList uses 0-based indexes, just like C++ arrays. To access the item at a particular index position, you can use operator[](). On |