Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qforeach.qdoc
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5 \macro forever
6 \relates <QForeach>
7
8 This macro is provided for convenience for writing infinite
9 loops.
10
11 Example:
12
13 \snippet code/src_corelib_global_qglobal.cpp 31
14
15 It is equivalent to \c{for (;;)}.
16
17 If you're worried about namespace pollution, you can disable this
18 macro by adding the following line to your \c .pro file:
19
20 \snippet code/src_corelib_global_qglobal.cpp 32
21
22 If using other build systems, you can add \c QT_NO_KEYWORDS to the
23 list of pre-defined macros.
24
25 \sa Q_FOREVER
26*/
27
28/*!
29 \macro Q_FOREVER
30 \relates <QForeach>
31
32 Same as \l{forever}.
33
34 This macro is available even when \c no_keywords is specified
35 using the \c .pro file's \c CONFIG variable.
36
37 \sa foreach()
38*/
39
40/*!
41 \macro foreach(variable, container)
42 \relates <QForeach>
43
44 This macro is used to implement Qt's \c foreach loop. The \a
45 variable parameter is a variable name or variable definition; the
46 \a container parameter is a Qt container whose value type
47 corresponds to the type of the variable. See \l{The foreach
48 Keyword} for details.
49
50 If you're worried about namespace pollution, you can disable this
51 macro by adding the following line to your \c .pro file:
52
53 \snippet code/src_corelib_global_qglobal.cpp 33
54
55 \note Since Qt 5.7, the use of this macro is discouraged.
56 Use C++11 range-based \c for, possibly with \c {std::as_const()},
57 as needed.
58*/
59
60/*!
61 \macro Q_FOREACH(variable, container)
62 \relates <QForeach>
63
64 Same as foreach(\a variable, \a container).
65
66 This macro is available even when \c no_keywords is specified
67 using the \c .pro file's \c CONFIG variable.
68
69 \note Since Qt 5.7, the use of this macro is discouraged.
70 Use C++11 range-based \c for, possibly with \c {std::as_const()},
71 as needed.
72*/