我已经用 Python/PyQt 翻译了在 C++/Qt 中运行良好的代码,但我不明白为什么它现在会产生错误。这是重现问题的最小代码:
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class A(QFrame):
def __init__(self, parent) :
QFrame.__init__(self, parent)
class B(A, QLine):
def __init__(self, parent) :
A.__init__(self, parent)
QLine.__init__(self, parent)
class C(B):
def __init__(self, parent) :
B.__init__(self, parent)
self.setLine(0, 0, 0, 0)
if __name__ == "__main__":
app = QApplication(sys.argv)
myApp = QMainWindow()
myApp.show()
c = C(myApp)
sys.exit(app.exec_())
运行此代码时,我收到消息“TypeError: could not convert 'C' to 'QLine'”... 为什么会这样?问题是什么?如何四处走动?