PyQt5, Qlabel text in multiple colors

Viewed 2398

how can i set multiple colors inside a Qlabel text? for example:

Qlabel.setText("Hello World!")

I want the "Hello" to be in blue, the "World" in red & the "!" in green is it possible?

I found that answer online for QT but this is not Python language:

ql->setText("<font color=\"blue\">Hello</font> <font color=\"red\">World</font><font color=\"green">!</font>");
1 Answers

It's easy, if you're familiar with HTML: Do something like this:

QLabel.setText('<font color="blue">Hello</font><font color="red"> World</font><font color="green">!</font>')

Hope this helps :)

Related