0

我一直试图让 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 需要的第二个参数是什么?

问题不应该出现在somedatafromlist1somedatafromlist2中。

我试图检查 self.lcdTimer 和 self.data2 几乎相同。

4

1 回答 1

0

让它工作。问题是几百行之后我还有其他对象(ImageQt),名称self.data1self.data2. def tick(time, self):实际上def tick(self, time):在我的代码中。

于 2011-09-15T06:21:17.763 回答