本页内容

qt_add_binary_resources

根据一组 Qt 资源文件创建一个 RCC 文件。

该命令定义在Qt6 包的Core 组件中,可按如下方式加载:

find_package(Qt6 REQUIRED COMPONENTS Core)

该命令于 Qt 5.10 版本中引入。

语法

qt_add_binary_resources(target file1.qrc [file2.qrc ...]
                        [DESTINATION ...]
                        [OPTIONS ...])

如果禁用了无版本号的命令,请改用 `qt6_add_binary_resources() `。它支持与本命令相同的参数集。

描述

添加一个自定义的target ,用于将Qt资源文件编译为二进制.rcc 文件。

参数

DESTINATION 设置生成的.rcc 文件的路径。默认值为${CMAKE_CURRENT_BINARY_DIR}/${target}.rcc 。

您可以设置应添加到rcc 调用中的额外OPTIONS 。可参考rcc文档了解可用选项。

示例

qt_add_binary_resources(resources project.qrc OPTIONS -no-compress)
add_dependencies(myapp resources)

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