简体   繁体   English

PyQt5,多个colors中的Qlabel文本

[英]PyQt5, Qlabel text in multiple colors

how can i set multiple colors inside a Qlabel text?如何在 Qlabel 文本中设置多个 colors? 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:我在网上找到了 QT 的答案,但这不是 Python 语言:

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

It's easy, if you're familiar with HTML: Do something like this:如果您熟悉 HTML,这很容易: 执行以下操作:

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

Hope this helps:)希望这可以帮助:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM