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 (&gt and &amp) but seem to display if I do not use the escape codes.

Here is what I am trying to get working...
Qt Code:
  1. QTextCursor cursor = textEdit->textCursor();
  2. cursor.insertHtml("<span style=\"color:#de0202\">&lt</span><span style=\"color:#000000\">A</span><span style=\"color:#0405be\">F</span><span style=\"color:#000000\">K</span><span style=\"color:#de0202\">&gt</span>");
To copy to clipboard, switch view to plain text mode 

And here is the output (normally with color)...
Qt Code:
  1. &ltAFK&gt
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 "&lt").

However...
Qt Code:
  1. cursor.insertHtml("&lt")
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