Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 QLabel,我用这样的新 .text 动态更新
self.ui.mylabel.text = 'foobar'
问题是之后它不会更新窗口上的新值。
我尝试调用self.app.processEvents()甚至更新标签本身self.ui.mylabel.update(),self.ui.mylabel.repaint()但无济于事。
self.app.processEvents()
self.ui.mylabel.update()
self.ui.mylabel.repaint()
如何让 QLabel 小部件反映更改?
我做错了。调用self.ui.mylabel.setText('foobar')而不是直接访问该属性完成了这项工作。
self.ui.mylabel.setText('foobar')