QT_NO_UTF8_SOURCE
防止强制将源文件视为 UTF-8 格式(适用于 Windows)。
该属性自 Qt 6.0 起引入。
在使用某些 Windows 编译器进行构建时,链接到 Qt 库的目标会使用标志强制编译器将其源文件视为 UTF-8。目前,此功能已针对 Visual Studio 和 Intel 编译器实现。您可以通过将该属性设置为 `TRUE`,按目标逐个禁用此行为:
set_property(TARGET target_name PROPERTY QT_NO_UTF8_SOURCE TRUE)注意:这 不会改变QString 等类的运行时行为(其来自const char * 的构造函数需要正确编码的UTF-8输入)。请使用QT_NO_CAST_FROM_ASCII 和QT_RESTRICTED_CAST_FROM_ASCII 宏来帮助识别此类代码。
另请参阅 qt_disable_unicode_defines()和qt_allow_non_utf8_sources()。
© 2026 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.