我有一个由 ui 文件定义并存储在 ui 子目录中的主窗口。
此主窗口正在使用一些图标。
这些图标存储在资源子目录中。如果resources.qrc 和resources.py 位于根目录,我没有错误并且图标显示良好。
我设法在资源子目录中有 resources.qrc 和 resources.py。当我编译主窗口 ui 文件时,我得到一个import resources_rc(或者如果我使用 --from-imports 选项,则来自 .import resources_rc )。
为了让 import 语句正常工作,我需要import resources.resources_rc。显然,我不想手动更改它,我希望使用 uic.exe 生成正确的导入语句。
这是resources.qrc的内容
<RCC>
<qresource prefix="resources">
<file>exit-128.png</file>
<file>Copy-48.png</file>
<file>New-48.png</file>
<file>Open_256.png</file>
<file>Paste-48.png</file>
<file>Save-48.png</file>
</qresource>
</RCC>
在 main_window.ui 中,有以下标签:
<resources>
<include location="../resources/resources.qrc"/>
</resources>