QT_EXCLUDE_FROM_TRANSLATION
该属性在 Qt 6.7 中引入。
将此目录属性设置为ON ,可将该目录及其子目录中的所有目标从翻译中排除。命令qt_collect_translation_source_targets()将跳过此类目标。
若要排除单个目标,请使用目标属性QT_EXCLUDE_FROM_TRANSLATION。
示例
在下面的示例中,不会从定义在tests 目录中的目标中提取可翻译字符串。
add_subdirectory(app)
add_subdirectory(tests)
set_property(DIRECTORY tests PROPERTY QT_EXCLUDE_FROM_TRANSLATION ON)
qt_add_translations(myapp)或者,您也可以在CMakeLists.txt 中将目录属性设置为tests 子目录。
# tests/CMakeLists.txt
qt_add_executable(...)
add_test(...)
set_directory_properties(PROPERTIES QT_EXCLUDE_FROM_TRANSLATION ON)© 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.