Resource Compiler (rcc)
rcc 工具用于在构建过程中将资源嵌入到 Qt 应用程序中。其工作原理是生成一个 C++ 源文件,其中包含 Qt 资源文件(.qrc)中指定的数据。
用法:
rcc [options] <inputs>RCC 支持以下命令行选项:
| 选项 | 参数 | 说明 |
|---|---|---|
-o | file | 将输出写入file 而非标准输出。 |
-g, --generator | <cpp|python|python2> | 选择生成器。 |
-name | name | 使用 `name` 创建一个外部初始化函数。 |
-threshold | level | 指定在决定是否压缩文件时使用的阈值level (以百分比表示)。如果文件大小的缩减幅度大于阈值level ,则进行压缩;否则,将存储未压缩的数据。 默认阈值水平为 70%,这意味着压缩后大小不超过原始大小 30% 的文件将作为压缩数据存储。 |
-compress-algo | algorithm | 用于压缩文件的算法。支持的算法包括zstd 、zlib 和none ,分别表示使用Zstandard库、zlib库进行压缩,以及不进行压缩。如果编译时找到了该库,则默认值为zstd ;否则,默认值为zlib 。 |
-compress | level | 将输入文件压缩至指定的压缩级别level ,该值取决于所选算法。若算法为zstd ,则有效级别范围为1至19,其中特殊值0和-1分别表示libzstd 和rcc 的默认压缩级别。 如果算法为zlib ,则级别是一个介于 1 到 9 之间的整数。对于这两种算法,级别 1 的压缩程度最低,但速度最快;级别 9 或 19 的压缩程度最高,但速度最慢。要关闭压缩,请使用-no-compress 。level 的默认值为 -1。 |
-root | path | 在资源访问路径前添加前缀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 应用程序中嵌入资源的更多信息。
© 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.