<QtDeprecationMarkers> - Qt Deprecation Macros
<QtDeprecationMarkers> 头文件包含贬值辅助宏。更多
Header: | #include <QtDeprecationMarkers> |
宏
宏文档
QT_DEPRECATED_WARNINGS
自 Qt 5.13 起,此宏不再有效。在 Qt 5.12 及之前的版本中,如果定义了此宏,编译器将在使用任何被 Qt 声明为过时的 API 时产生警告。
另请参阅 QT_DISABLE_DEPRECATED_UP_TO 和QT_NO_DEPRECATED_WARNINGS 。
QT_DISABLE_DEPRECATED_UP_TO
可在项目文件中定义该宏,以禁用指定版本的 Qt 或任何更早的版本中废弃的函数。默认的版本号是 5.0,这意味着在 Qt 5.0 或更早版本中被弃用的函数将不会被包含在内。
例如,当准备升级到 Qt 6.3 时,在消除所有弃用警告后,您可以设置QT_DISABLE_DEPRECATED_UP_TO=0x060300
,将不再使用的 Qt API 从联编中排除。在你自己项目的构建配置中,这将确保任何人在添加对已废弃 API 的新调用时,都能立即了解到这一点。如果你也为自己编译 Qt,那么在 Qt 的编译配置中包含此定义,甚至可以省略弃用 API 的实现,从而使你的二进制文件更小。
注意: 为避免链接器出错,整个二进制文件应始终使用相同的弃用级别。这意味着在静态联编时,Qt XML 库也应在QT_DISABLE_DEPRECATED_UP_TO
设置为与用户代码中相同的版本。这是因为在静态联编时,Qt 库也会成为二进制文件的一部分。
另请参阅 QT_DEPRECATED_WARNINGS 和 QT_DISABLE_DEPRECATED_UP_TO。
QT_NO_DEPRECATED_WARNINGS
使用该宏可以抑制在使用已废弃 API 时产生的废弃警告。
另请参见 QT_DISABLE_DEPRECATED_UP_TO 。
© 2025 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.