使用 PyQt 的资源系统的问题 [英] Problems using PyQt's Resource System

查看:29
本文介绍了使用 PyQt 的资源系统的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 PyQt 的资源系统,但似乎我不知道我在做什么!我已经创建了应用程序及其 GUI 我只是想导入一些图像以与程序一起使用.

I am trying to use PyQt's Resource System but it appears I have no clue what I am doing! I already have to application created, along with its GUI I am just trying to import some images to use with the program.

我使用 QtDesigner 创建资源文件,并使用 pyrcc4.exe 编译它.但是当我尝试导入资源文件时,出现此错误:

I used the QtDesigner to create the resource file and I compiled it using pyrcc4.exe. But when I attempt to import the resource file I get this error:

Traceback (most recent call last):
  File "C:\Projects\main.py", line 14, in <module>
    import main_rc
  File "C:\Projects\main_rc.py", line 482, in <module>
    qInitResources()
  File "C:\Projects\main_rc.py", line 477, in qInitResources
    QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
      TypeError: argument 2 of qRegisterResourceData() has an invalid type

我做错了什么?

推荐答案

pyrcc 默认生成 Python 2.x 代码.

pyrcc generates Python 2.x code by default.

尝试使用带有-py3"标志的 pyrcc 重新生成资源文件

Try regenerating your resource files using pyrcc with flag '-py3'

这篇关于使用 PyQt 的资源系统的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆