qt_add_big_resources
将大型二进制资源编译为目标代码。
该命令定义在Qt6 包的Core 组件中,可按如下方式加载:
find_package(Qt6 REQUIRED COMPONENTS Core)该命令于 Qt 5.12 版本中引入。
语法
qt_add_big_resources(<VAR> file1.qrc [file2.qrc ...]
[OPTIONS ...])如果禁用了无版本号的命令,请改用qt6_add_big_resources() 。它支持与本命令相同的参数集。
描述
使用Resource Compiler (rcc)从 Qt 资源文件生成编译后的对象文件。生成的文件路径将被添加到<VAR> 中。
这与qt_add_resources() 类似,但直接生成对象文件(.o 、.obj ),而非 C++ 源代码。这使得嵌入更大规模的资源成为可能——若先编译为 C++ 源代码再生成二进制文件,将耗费过多时间或占用过多内存。
注意: file1.qrc 不会被Qt Creator 视为源文件。需要将其作为源文件添加到 CMake 目标中,并将属性SKIP_AUTORCC 设置为ON 。
警告: 在构建 iOS 版本时,此 命令不受支持,请改用qt_add_resources()。详情请参阅QTBUG-103497。
参数
您可以设置额外的OPTIONS ,这些选项将被添加到rcc 调用中。可在rcc文档中查阅可用选项。
示例
set(SOURCES main.cpp)
qt_add_big_resources(SOURCES big_resource.qrc)
# Have big_resource.qrc treated as a source file by Qt Creator
list(APPEND SOURCES big_resource.qrc)
set_property(SOURCE big_resource.qrc PROPERTY SKIP_AUTORCC ON)
qt_add_executable(myapp ${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.