Using QSyntaxHighlighter from Python
Dynamic Python binding for Qt Applications
Brought to you by:
florianlink,
marcusbarann
Is it possible to use QSyntaxHighlighter from Python? I've tried subclassing QSyntaxHighlighter but I can't figure out how to deal with the highlightBlock method which is a pure virtual method inside QSyntaxHighlighter. This method needs to be implemented in the derived class. It seems like PythonQt created a placeholder for this function but I'm not sure if I can replace it or if I have to implement the highlighter in C++.
I tried the code below but it doesn't seem to call the highlightBlock() method:
I found the problem... The constructor of QSyntaxHighlighter has three overloads and PythonQt chooses the first one, which is QObject. So the solution is to do an extra setDocument() call.
The following works for me:
Sorry, I forgot to reply to this. Your solution did work! Thanks for your help. Your project is awesome.