创建资源文件

Qt 资源系统是一种独立于平台的机制,用于在应用程序的可执行文件中存储文件。

要创建资源文件

  1. 选择File >New File >Qt >Qt Resource File >Choose

    新建文件对话框

  2. 按照向导的指示创建资源集合文件(.qrc)。
  3. 在资源编辑器中打开资源文件。

    编辑资源文件

  4. 选择Add Files 查找并添加单个文件。

对资源文件排序

要在源代码树中按字母升序排列文件夹和文件,请在右键菜单中选择Sort Alphabetically

设置路径前缀

默认情况下,应用程序中的资源可通过与源代码树中相同的文件名(带:/ 前缀)或带qrc 方案的 URL 访问。要为.qrc 文件中的所有文件指定路径前缀,请选择Add Prefix ,然后在Prefix 字段中输入前缀。

设置地域

有些资源需要根据用户的地域进行更改,如翻译文件或图标。您可以在Language 字段中指定区域设置。

使用小写双字母ISO 639 语言代码,如deenfr

删除资源文件

选择Remove 可从资源集中删除所选文件。

Remove File 对话框中,选择Delete file permanently 复选框可从文件系统中删除文件。

删除文件对话框

要删除在文件系统中找不到的文件,请选择Remove Missing Files

上述功能也可在项目视图的上下文菜单中使用。

另请参阅 创建文件使用项目向导QLocale

Copyright © The Qt Company Ltd. and other contributors. 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.