QSyntaxHighlighter is not meant to work with rich text. You have to do your own parsing and coloring by injecting QTextCharFormat objects directly into your document.