QLabel.setText() 不起作用?
我已经尝试让 QLabel.setText 在 PySide 中工作好几天了,但没有成功。
我有以下代码(简化):
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 几乎相同。
I have been trying to get QLabel.setText in PySide working for several days, but no succes.
I have following code(simplified):
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
So, why I get an errors like this:
self.data2.display(somedatafromlist2)
AttributeError: 'PySide.QtGui.QImage' object has no attribute 'display'
self.data1.setText(somedatafromlist1)
TypeError: setText expected 2 arguments, got 1
And why is lcdTimer.display() working, but the other ones not.
What is the second argument .setText neededs?
The problem should not be in the somedatafromlist1 or somedatafromlist2.
I have tried to check out that self.lcdTimer and self.data2 are almost identical.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
让它发挥作用。问题是,几百行后我还有其他对象(ImageQt),名称为
self.data1
和self.data2
。def tick(time, self):
实际上是我的代码中的def tick(self, time):
。Get it working. Problem was that I had also other objects(ImageQt) a few hundreds lines later with names
self.data1
andself.data2
.def tick(time, self):
was actuallydef tick(self, time):
in my code.