PySide & Python3: TypeError on QAction



我很困惑。我在 Ubuntu 13.10 下使用 Python3 运行 PySide。我无法通过我的测试套件出错的简单任务;我将问题缩小到两行:

from PySide.QtGui import QAction
a = QAction("Test")

就是这样。如果我只是直接在/usr/bin/python3 解释器 (v3.3.2) 中运行这两行,它会对我大喊大叫:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'PySide.QtGui.QAction' called with wrong argument types:
  PySide.QtGui.QAction(str)
Supported signatures:
  PySide.QtGui.QAction(PySide.QtCore.QObject)
  PySide.QtGui.QAction(PySide.QtGui.QIcon, unicode, PySide.QtCore.QObject)
  PySide.QtGui.QAction(unicode, PySide.QtCore.QObject)

我真的不知道这应该意味着什么。我认为 Python3 中的所有 (str) 字符串都是 unicode。Qhy PySide 是否抱怨不是隐含的相同类型(str <=> unicode)?

欢迎任何帮助,我在这里迷路了。

天哪,我又做了一次。 发布到堆栈溢出后 1 分钟,经过几个小时的令人沮丧的工作,我得到了解决方案;-)

解决方案很简单:它与 str - unicode 转换无关。QAction至少需要一个文本参数(str,bytes,unicode...)和一个父级(QObject 衍生物) - 我忘记了这一点,只是没有就足够了。

最新更新