MobileRead Forums

MobileRead Forums (https://www.mobileread.com/forums/index.php)
-   Development (https://www.mobileread.com/forums/forumdisplay.php?f=240)
-   -   Setting colour of text in QT QLabel (https://www.mobileread.com/forums/showthread.php?t=224605)

Agama 10-12-2013 04:15 AM

Setting colour of text in QT QLabel
 
Is there a simple means for setting the colour of text in a QLabel widget? There doesn't seem to be a property for this and the documentation only mentions text colour in the context of displaying small rich text documents.

kovidgoyal 10-12-2013 04:19 AM

Use <span style="color:red">your text</span>

or if you dont want to use rich text

label.setStylesheet('QLabel { color: red }')

or if you dont want to use stylesheets:

pal = QPalette(label.palette())
pal.setColor(QPalette.WindowText, QColor(Qt.red))
label.setPalette(pal)

Agama 10-12-2013 04:28 AM

Thanks. I tried the rich text method and it works a treat. :)


All times are GMT -4. The time now is 10:55 PM.

Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.