[Solved] QTextDocument with < and > characters



  • I'm using QTextDocument to set the appearance of fields. I use:

    htmlText.setHtml("<div align=center>mytext</div>

    When mytext is composed of numerals and normal characters, everything is fine, but in one case I'd like to display the string "<80" in the field. This doesn't work (I would assume because the parser sees the < character and figures it's a new section). How can I include the < or > characters in an html string?


  • Moderators

    < and > are special characters in html. To display them literally you can use entities: &lt; and &gt; i.e. &lt;80 will result in <80.
    For a list of possible entities you can scout the web, e.g. here.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.