本页内容

创建资源文件

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.