Lorenzo
Lorenzo

Reputation: 4658

PyQt update QLabel

I have a QLabel that I dynamically update with a new .text like this

self.ui.mylabel.text = 'foobar'

The problem is that after that it doesn't update the new value on the window.

I tried calling self.app.processEvents() or even an update on the label itself self.ui.mylabel.update() and self.ui.mylabel.repaint() to no avail.

How do I get the QLabel widget to reflect the change?

Upvotes: 3

Views: 10873

Answers (1)

Lorenzo
Lorenzo

Reputation: 4658

I was doing it wrong. Calling self.ui.mylabel.setText('foobar') rather than accessing the property directly did the job.

Upvotes: 8

Related Questions