Resource Compiler (rcc)

rcc 工具用于在构建过程中将资源嵌入 Qt 应用程序。它的工作原理是生成一个 C++ 源文件,其中包含 Qt 资源 (.qrc) 文件中指定的数据。

使用方法

rcc [options] <inputs>

RCC 接受以下命令行选项:

选项参数说明
-ofile将输出写入file 而不是 stdout。
-g, --generator<cpp|python|python2>选择生成器。
-namename使用name 创建外部初始化函数。
-thresholdlevel指定用于决定是否压缩文件的阈值level (百分比)。如果文件大小的减少量大于阈值level ,则对文件进行压缩;否则,将存储未压缩的数据。默认的阈值水平是 70%,这意味着压缩后的文件如果只有原始大小的 30%或更小,就会作为压缩数据存储。
-compress-algoalgorithm压缩文件的算法。支持的算法有zstdzlibnone ,分别表示使用Zstandard库、zlib库和不压缩来压缩内容。如果编译时找到该库,默认值为zstd ;如果找不到,默认值为zlib
-compresslevel按给定的压缩方式压缩输入文件level ,压缩方式取决于算法。如果算法为zstd ,有效级别为 1 到 19,特殊值 0 和 -1 表示libzstdrcc 的默认压缩方式。如果算法是zlib ,则级别是 1 到 9 范围内的整数。对于这两种算法,1 级的压缩率最低,但速度最快。级别 9 或 19 的压缩量最大,但速度最慢。要关闭压缩,请使用-no-compresslevel 的默认值为-1。
-rootpath使用path 作为资源访问路径的前缀。默认值为无前缀。
-no-compress禁用压缩。
--no-zstd禁用zstd 压缩。
--pass<number>为大资源传递编号
-binary输出二进制文件作为动态资源使用。
-version显示版本信息。
-help显示使用信息。
-t, --temp <file>对大型资源使用临时 <file>。
--namespace关闭命名空间宏。
--verbose启用详细说明模式
--list只列出 .qrc 文件条目,不生成代码。
--list-mapping只输出资源路径与 .qrc 文件中定义的文件系统路径的映射,不生成代码。
-d, --depfile<file>将包含 .qrc 依赖项的 depfile 写入 <file>。
-project输出包含当前目录下所有文件的资源文件。
--format-version<number>要写入的 RCC 格式版本。

另请参阅 "Qt 资源系统",了解有关在 Qt 应用程序中嵌入资源的更多信息。

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