The <QtGlobal> header file includes an assortment of other headers. 更多...
| 头: |
#include <QtGlobal>
|
(从 6.8 起)
|
QT_ENABLE_STRICT_MODE_UP_TO |
(从 6.0 起)
|
QT_NO_FOREACH |
| QT_NO_KEYWORDS |
Up to Qt 6.5, most Qt header files included <QtGlobal>. Before Qt 6.5, <QtGlobal> defined an assortment of global declarations. Most of these have moved, at Qt 6.5, to separate headers, so that source code can include only what it needs, rather than the whole assortment. For now, <QtGlobal> includes those other headers (see next section), but future releases of Qt may remove some of these headers from <QtGlobal> or condition their inclusion on a version check. Likewise, in future releases, some Qt headers that currently include <QtGlobal> may stop doing so. The hope is that this will improve compilation times by avoiding global declarations when they are not used.
| 头 | 摘要 |
|---|---|
| < QFlags > | Type-safe way of combining enum values |
| <QForeach> | Qt's implementation of foreach and forever loops |
| <QFunctionPointer> | Typedef for a pointer-to-function type |
| <QApplicationStatic> | For Q_APPLICATION_STATIC |
| < QGlobalStatic > | Thread-safe initialization of global static objects |
| <QOverload> | Helpers for resolving member function overloads |
| < QSysInfo > | A helper class to get system information |
| <QTypeInfo> | Helpers to get type information |
| <QtAssert> | Q_ASSERT and other runtime checks |
| <QtClassHelperMacros> | Qt class helper macros |
| <QtCompilerDetection> | Compiler-specific macro definitions |
| <QtDeprecationMarkers> | Deprecation helper macros |
| <QtEnvironmentVariables> | Helpers for working with environment variables |
| <QtExceptionHandling> | Helpers for exception handling |
| <QtLogging> | Qt logging helpers |
| <QtMalloc> | Memory allocation helpers |
| <QtMinMax> | Helpers for comparing values |
| <QtNumeric> | Various numeric functions |
| <QtPreprocessorSupport> | Helper preprocessor macros |
| <QtProcessorDetection> | Architecture-specific macro definitions |
| <QtResource> | Helpers for initializing and cleaning resources |
| <QtSwap> | Implementation of qSwap () |
| <QtSystemDetection> | Platform-specific macro definitions |
| <QtTranslation> | Qt translation helpers |
| <QtTypeTraits> | Qt type traits |
| <QtTypes> | Qt fundamental type declarations |
| <QtVersionChecks> | QT_VERSION_CHECK and related checks |
| <QtVersion> | QT_VERSION_STR and qVersion () |
[since 6.8]
QT_ENABLE_STRICT_MODE_UP_TO
Defining this macro will disable a number of Qt APIs that are deemed suboptimal or dangerous.
This macro's value must be set to a Qt version, using
QT_VERSION_CHECK
's encoding. For instance, in order to set it to Qt 6.6, define
QT_ENABLE_STRICT_MODE_UP_TO=0x060600
. This will disable only the APIs introduced in versions up to (and including) the specified Qt version.
若 QT_DISABLE_DEPRECATED_UP_TO macro is not defined, then QT_ENABLE_STRICT_MODE_UP_TO will define it as well, to the same value.
This macro should always be set to the minimum Qt version that your project wants to support.
The APIs disabled by this macro are listed in the table below, together with the minimum value to use in order to disable them.
| 版本 | Disabled APIs |
|---|---|
| 6.0.0 | foreach (见 QT_NO_FOREACH ) |
| 6.0.0 |
QString
conversions towards
const char *
/
QByteArray
(见
QT_NO_CAST_TO_ASCII
)
|
| 6.0.0 |
QByteArray
implicit conversions towards
const char *
(见
QT_NO_CAST_FROM_BYTEARRAY
)
|
| 6.0.0 | QUrl implicit conversions from QString (见 QT_NO_URL_CAST_FROM_STRING ) |
| 6.0.0 | Allowing narrowing conversions in signal-slot connections (see QT_NO_NARROWING_CONVERSIONS_IN_CONNECT ) |
| 6.0.0 | Java-style iterators for Qt containers |
| 6.6.0 | The qExchange () function (see QT_NO_QEXCHANGE ) |
| 6.7.0 | Overloads of QObject::connect that do not take a context object (see QT_NO_CONTEXTLESS_CONNECT ) |
| 6.8.0 | The qAsConst() function (see QT_NO_QASCONST ) |
| 6.8.0 |
File-related I/O classes have their
open()
functions marked
[[nodiscard]]
(见
QT_USE_NODISCARD_FILE_OPEN
)
|
| 6.9.0 | The qsnprintf() and qvnprintf() functions (see QT_NO_QSNPRINTF ). |
Moreover, individual APIs may also get disabled as part of the setting of QT_DISABLE_DEPRECATED_UP_TO . Please refer to each class' documentation for more details.
该宏在 Qt 6.8 引入。
另请参阅 QT_DISABLE_DEPRECATED_UP_TO , QT_NO_KEYWORDS ,和 QT_VERSION_CHECK .
[since 6.0]
QT_NO_FOREACH
Defining this macro removes the availability of Qt's
foreach
循环。
该宏在 Qt 6.0 引入。
另请参阅 QT_NO_KEYWORDS .
Define this macro to disable the Qt-specific keywords that are usually enabled, such as
signals
and
slots
。使用
Q_SIGNALS
and
Q_SLOTS
代替。
Libraries should define this macro to make sure that they don't use the generic keywords without the
Q_
prefix in their public headers.
另请参阅 QT_NO_FOREACH .