PDA

View Full Version : How to hange color for different texts in plaintextedit?



sudhansu
13th August 2010, 10:07
Hi All,

I've a plain text edit in myt dialog. i want to write "XYZ " in red color and "ABC" in black color. How can i do this? i tried to set pallet. but its not working. I've attached sample code of my apllication. please help me.

Thank you.

Stiander
13th August 2010, 13:08
try this:


yourTextEdit->append("<font color = red>XYZ</font>");

Lykurg
13th August 2010, 13:16
yourTextEdit->append("<font color = red>XYZ</font>");That wont work for a QPlainTextEdit. But you can set a syntaxhighlighter. See the "Syntax Highlighter Example" in the docs or direct QSyntaxHighlighter. Or you can use the the basic options of the text cursor which should be the fastest appproach. See QTextCursor and QTextCharFormat.

Stiander
13th August 2010, 13:36
oh yea thats right. would work for QTextBrowser tho, and I think QTextEdit