Hello,
I am working on a simple program that needs to display colored text in a QTextEdit. I am using html and a css style within <span></span> tags to set the colors of the text. It works fine, except I can not get the text to display the less than symbol (<) with color. The greater than (>) and ampersand (&) have the same problem as < when using their escape codes (> and &) but seem to display if I do not use the escape codes.
Here is what I am trying to get working...
cursor.insertHtml("<span style=\"color:#de0202\"><</span><span style=\"color:#000000\">A</span><span style=\"color:#0405be\">F</span><span style=\"color:#000000\">K</span><span style=\"color:#de0202\">></span>");
QTextCursor cursor = textEdit->textCursor();
cursor.insertHtml("<span style=\"color:#de0202\"><</span><span style=\"color:#000000\">A</span><span style=\"color:#0405be\">F</span><span style=\"color:#000000\">K</span><span style=\"color:#de0202\">></span>");
To copy to clipboard, switch view to plain text mode
And here is the output (normally with color)...
<AFK>
<AFK>
To copy to clipboard, switch view to plain text mode
The problem is, instead of escaping the symbols, qt is displaying the text within the QString (such as "<").
However...
cursor.insertHtml("<")
cursor.insertHtml("<")
To copy to clipboard, switch view to plain text mode
properly displays "<" (without color). I just can't get it to display the escaped characters when it is within the span tags.
Note: When I put this same line of html in a web page, it displayed properly with the escape codes being replaced by the appropriate characters.
Any help or suggestions would be greatly appreciated.
Thanks,
JvIasterMind
Bookmarks