Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyQt update QLabel

Tags:

qt

pyqt

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?

like image 710
Lorenzo Avatar asked Nov 27 '25 14:11

Lorenzo


1 Answers

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

like image 71
Lorenzo Avatar answered Dec 01 '25 15:12

Lorenzo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!