2013-10-30 27 views
0

我很困惑。我在Ubuntu 13.10下使用Python3運行PySide。 我無法通過一個簡單的任務,其中我的測試套件發生錯誤;我把問題縮小到雙線:PySide&Python3:QAction上的TypeError

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)?

任何幫助歡迎,我迷失在這裏。

回答

2

OMG,我又做了。在發佈到stackoverflow後1分鐘,我得到了解決方案,經過幾小時的挫折工作之前;-)

解決方案很簡單:它與str - unicode轉換無關。 QAction至少需要一個文本參數(str,bytes,unicode ...)和一個父級(一個QObject派生) - 我忘了這個,只是沒有就夠了。