<QtDeprecationMarkers> - Qt Deprecation Macros

The <QtDeprecationMarkers> header file contains deprecation helper macros. More...

Header: #include <QtDeprecationMarkers>

Macros

Detailed Description

The header file declares several macros for disabling deprecated Qt APIs and enabling/disabling compiler warnings when they are used.

Macro Documentation

QT_DEPRECATED_WARNINGS

Since Qt 5.13, this macro has no effect. In Qt 5.12 and before, if this macro is defined, the compiler will generate warnings if any API declared as deprecated by Qt is used.

See also QT_DISABLE_DEPRECATED_UP_TO and QT_NO_DEPRECATED_WARNINGS.

QT_DISABLE_DEPRECATED_UP_TO

This macro can be defined in the project file to disable functions deprecated in a specified version of Qt or any earlier version. The default version number is 5.0, meaning that functions deprecated in or before Qt 5.0 will not be included.

For instance, when preparing to upgrade to Qt 6.3, after eliminating all deprecation warnings, you can set QT_DISABLE_DEPRECATED_UP_TO=0x060300 to exclude from your builds the Qt APIs you no longer use. In your own project's build configuration, this will ensure that anyone adding new calls to the deprecated APIs will know about it right away. If you also build Qt for yourself, including this define in your build configuration for Qt will make your binaries smaller by leaving out even the implementation of the deprecated APIs.

Note: In order to avoid linker errors, the same deprecation level should be used consistently in the entire binary. This means that in static builds the Qt libraries should also be built with QT_DISABLE_DEPRECATED_UP_TO set to the same version as in the user code. That is because in static build the Qt libraries also become a part of the binary.

See also QT_DEPRECATED_WARNINGS and QT_DISABLE_DEPRECATED_UP_TO.

QT_NO_DEPRECATED_WARNINGS

This macro can be used to suppress deprecation warnings that would otherwise be generated when using deprecated APIs.

See also QT_DISABLE_DEPRECATED_UP_TO.

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.