本页内容

QT_EXCLUDE_SOURCES_FROM_TRANSLATION

该属性自 Qt 6.7 起引入。

此目标属性指定了一组将被排除在翻译之外的源文件路径。lupdate 会忽略与该排除列表中模式匹配的源文件。

路径可以是绝对路径,也可以是相对于CMAKE_CURRENT_SOURCE_DIR 的相对路径。路径中可以包含符合QRegularExpression::wildcardToRegularExpression 所支持格式的通配符。

示例

排除untranslatable.cpp 以及3rdparty 目录下的所有文件(包括子目录中的文件)。

qt_add_executable(myapp
    main.cpp
    untranslatable.cpp
    3rdparty/sqlite/sqlite3.h
    3rdparty/sqlite/sqlite3.c
    3rdparty/zlib/src/gzlib.c
    3rdparty/zlib/src/zlib.h
)
set_property(TARGET myapp PROPERTY QT_EXCLUDE_SOURCES_FROM_TRANSLATION
    untranslatable.cpp
    3rdparty/*
)

另请参阅 qt_add_lupdate()、目标属性 QT_EXCLUDE_FROM_TRANSLATION 以及目录属性 QT_EXCLUDE_FROM_TRANSLATION。

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