2

I want specific words to be colored with specific colors. For example all instances of the word "one" will be colored in red, "two" in blue and the rest is plain text.

How it is done?

user1952686
  • 339
  • 1
  • 4
  • 12
  • This might help you: http://stackoverflow.com/questions/14885481/how-to-highlight-a-string-of-text-within-a-qtextedit. – cdonts Jul 09 '14 at 14:33

1 Answers1

2

You can do this by subclassing QSyntaxHighlighter and defining your formatting rules. You then create an instance of your subclass and make the QTextEdit you want to apply the formatting to its parent.

Take a look here for an example of how to do it

user3419537
  • 4,740
  • 2
  • 24
  • 42