[Qt-interest] HTML formatting tags with QPainter::drawText
Andre Somers
andre at familiesomers.nl
Wed Feb 17 15:26:35 CET 2010
Sonic wrote:
> Hi
>
> Limited HTML formatting tags work when displaying text using a QLabel.
> For example, "Hello <b>world</b>" will display "hello" in normal width
> and "world" in bold.
>
> I want to display some text using QPainter::drawText (or something
> similar, in a widget's paintEvent) and I want to use this formatting
> feature. But just calling drawText with the above mentioned string will
> only print it as it is - i.e. the tags get printed as such.
>
> Can anybody suggest a solution to this?
>
Sure. Use a QTextDoment for your rich text, and then use drawContents to
render it.
André
More information about the Qt-interest-old
mailing list