[Interest] Don't get expected result from drawing StaticText with HTML

Martin Marmsoler martin.marmsoler at gmail.com
Tue May 14 20:07:14 CEST 2019


Hello,

I'm trying to draw a static text from html code received from a QTextEdit.
The first time I set the text normaly without html:
teLabel->setText("Textmarke");

then I mark in the TextEdit field the part "arke" of the above text and
change the color with

teLabel->setTextColor(color);


>From the textEdit I get the following HTML Code:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "
http://www.w3.org/TR/REC-html40/strict.dtd">

<html><head><meta name="qrichtext" content="1" /><style type="text/css">

p, li { white-space: pre-wrap; }

</style></head><body style=" font-family:''; font-size:12pt;
font-weight:400; font-style:normal;">

<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px;
margin-right:0px; -qt-block-indent:0; text-indent:0px;">Textm<span style="
color:#ff0000;">arke</span></p></body></html>


I store this String in a QStaticText (staticText) and draw this text with

painter->drawStaticText(QPoint(-w/2,-h/2), staticText);


But the result is that the hole text is red and not only the part "arke"


Do anybody know why I get the complete text red and not only a part?


Best regards,


Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190514/6b73573b/attachment.html>


More information about the Interest mailing list