PDA

View Full Version : Using QSyntaxHighlighter



chris_helloworld
5th October 2010, 12:22
I've just modified my application to use a QSyntaxHighlighter for highlighting a QTextEdit. (I was previously doing the syntax highlighting using setCharFormat on the document itself which was causing issues with undo / redo).

Using the QSyntaxHighlighter works well with one slight glitch, copying, (Ctrl-c), the text from the QTextEdit doesn't copy the syntax highlighting, (not suprising given the highlighting is no longer stored within the document).

One approach to solving this problem would be to reimplement copy, and create a temporary text document with my highlighting applied to it. This seems a bit clunky and I wonder if theres a better way.

Any ideas ?
Cheers,
Chris.