You need to subclass QSyntaxHighlighter and override:
QSyntaxHighlighter::highlightParagraph()
This function is called when necessary (the given paragraph has changed).
Just pass the text edit object to QSyntaxHighlighter's constructor. It will then install the syntax highlighter on the text edit.
QSyntaxHighlighter::QSyntaxHighlighter(QTextEdit* textEdit):
Constructs the QSyntaxHighlighter and installs it on textEdit.
It is the caller's responsibility to delete the QSyntaxHighlighter when it is no longer needed.
Bookmarks