<QForeach>

Helper macros for performing for-loops. 更多...

頭: #include <QForeach>

Q_FOREACH ( variable , container )
Q_FOREVER
foreach ( variable , container )
forever

詳細描述

宏文檔編製

Q_FOREACH ( variable , container )

如同 foreach( variable , container ).

此宏可用,甚至 no_keywords 的指定是使用 .pro 文件的 CONFIG 變量。

注意: Since Qt 5.7, the use of this macro is discouraged. Use C++11 range-based for , possibly with std::as_const() , as needed.

Q_FOREVER

如同 forever .

此宏可用,甚至 no_keywords 的指定是使用 .pro 文件的 CONFIG 變量。

另請參閱 foreach ().

foreach ( variable , container )

此宏用於實現 Qt 的 foreach 循環。 variable parameter is a variable name or variable definition; the container parameter is a Qt container whose value type corresponds to the type of the variable. See foreach 關鍵字 瞭解細節。

If you're worried about namespace pollution, you can disable this macro by adding the following line to your .pro 文件:

CONFIG += no_keywords
					

注意: Since Qt 5.7, the use of this macro is discouraged. Use C++11 range-based for , possibly with std::as_const() , as needed.

forever

This macro is provided for convenience for writing infinite loops.

範例:

forever {
    ...
}
					

它相當於 for (;;) .

If you're worried about namespace pollution, you can disable this macro by adding the following line to your .pro 文件:

CONFIG += no_keywords
					

If using other build systems, you can add QT_NO_KEYWORDS to the list of pre-defined macros.

另請參閱 Q_FOREVER .