我一直试图让 PySide 中的 QLabel.setText 工作了几天,但没有成功。
我有以下代码(简化):
def GUI(self):
self.data1=QtGui.QLabel()
self.data2=QtGui.QLCDNumber()
self.lcdTimer=QtGui.QLCDNumber()
def tick(time, self):
self.lcdTimer.display(timetodisplay) ## this one works
self.data1.setText(somdatafromlist1) ## this one not
self.data2.display(somedatafromlist2) ## this one not
那么,为什么我会收到这样的错误:
self.data2.display(somedatafromlist2)
AttributeError: 'PySide.QtGui.QImage' object has no attribute 'display'
self.data1.setText(somedatafromlist1)
TypeError: setText expected 2 arguments, got 1
以及为什么 lcdTimer.display() 工作,但其他的没有。.setText 需要的第二个参数是什么?
问题不应该出现在somedatafromlist1或somedatafromlist2中。
我试图检查 self.lcdTimer 和 self.data2 几乎相同。