QLabel is a very dynamic widget. It can be use to display text (definitely), graphic and even gif animation (this can be done by calling setMovie function). But one think that I like very much is the capability to display rich text. With a markup similar to http, you can actually shown text like: "This is sample text and this is bold sample text".
Yup, you can mix up bold text with the normal text and even more.
You can check here for the supported html tag.
One of the supported html tag is <a> for hyperlink.
If you have try it, you might be wondering "How to change the color of the text?".
It took me a while to find the solution for this.
And the answer is simple, you have to code it to the tag.
If you want the text above displayed in red color, you have to set the text property of the QLabel to the following:
<a href="myref" style="color: red">This is sample text and <b>this is bold sample text</b></a>
No comments:
Post a Comment