<QtGlobal> Proxy Page

Macros

Macro Documentation

[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.

If the 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.

VersionDisabled APIs
6.0.0foreach (see QT_NO_FOREACH)
6.0.0QString constructors from const char * (see QT_NO_CAST_FROM_ASCII)
6.0.0QString conversions towards const char * / QByteArray (see QT_NO_CAST_TO_ASCII)
6.0.0QByteArray implicit conversions towards const char * (see QT_NO_CAST_FROM_BYTEARRAY)
6.0.0QUrl implicit conversions from QString (see QT_NO_URL_CAST_FROM_STRING)
6.0.0Allowing narrowing conversions in signal-slot connections (see QT_NO_NARROWING_CONVERSIONS_IN_CONNECT)
6.0.0Java-style iterators for Qt containers
6.6.0The qExchange() function (see QT_NO_QEXCHANGE)
6.7.0Overloads of QObject::connect that do not take a context object (see QT_NO_CONTEXTLESS_CONNECT)
6.8.0The qAsConst() function (see QT_NO_QASCONST)
6.8.0File-related I/O classes have their open() functions marked [[nodiscard]] (see QT_USE_NODISCARD_FILE_OPEN)

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.

This macro was introduced in Qt 6.8.

See also QT_DISABLE_DEPRECATED_UP_TO, QT_NO_KEYWORDS, and QT_VERSION_CHECK.