<QtGlobal>

The <QtGlobal> header file includes an assortment of other headers. More...

Header: #include <QtGlobal>

Macros

Detailed Description

\inmoduleQtCore \title Global Qt Declarations \ingroup funclists

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.

List of Headers Extracted from <QtGlobal>

HeaderSummary
<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
<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()

Macro Documentation

QT_TERMINATE_ON_EXCEPTION(expr)

\internal

In general, use of the Q_DECL_NOEXCEPT macro is preferred over Q_DECL_NOTHROW, because it exhibits well-defined behavior and supports the more powerful Q_DECL_NOEXCEPT_EXPR variant. However, use of Q_DECL_NOTHROW has the advantage that Windows builds benefit on a wide range or compiler versions that do not yet support the C++11 noexcept feature.

It may therefore be beneficial to use Q_DECL_NOTHROW and emulate the C++11 behavior manually with an embedded try/catch.

Qt provides the QT_TERMINATE_ON_EXCEPTION(expr) macro for this purpose. It either expands to expr (if Qt is compiled without exception support or the compiler supports C++11 noexcept semantics) or to

     try { expr; } catch(...) { qTerminate(); }

otherwise.

Since this macro expands to just expr if the compiler supports C++11 noexcept, expecting the compiler to take over responsibility of calling std::terminate() in that case, it should not be used outside Q_DECL_NOTHROW functions.

See also Q_DECL_NOEXCEPT, Q_DECL_NOTHROW, and qTerminate().

qMove(x)

\deprecated

Use std::move instead.

It expands to "std::move".

qMove takes an rvalue reference to its parameter x, and converts it to an xvalue.