Porting Qt highlighting example code to PyQt4
[Edit]See post #2 for a simplified version of the problem (I think)[/Edit]
Hello everyone, I'm trying to port the Qt syntax highlighting example to PyQt4 and I am having a few problems. The code seems to work but nothing is highlighted and sometimes (when i try to modify the beginning of a line or the end of a line that should be highlighted), I get stucked in a infinite loop. Here is the example code : http://qt.nokia.com/doc/4.0/richtext...ghlighter.html And here is mine : Code:
#!/usr/bin/python Code:
QtCore.QObject.connect(self.ui_prefs.textEdit.document(),\ Code:
def highlight1(self, position, removed, added): I have re-read the code a thousand times and I can't find what I missed. If anyone has an idea, I'd be happy to hear it !! :) Thanks ! |
Things have changed a little but the problem is the same...
I found out that there was a QSyntaxHighlighter class that sould handle syntax highlighting problems : http://www.riverbankcomputing.co.uk/...ghlighter.html I tried making a new app so I would be sure I didn't miss anything and I'm still stuck in an infinite loop... I did copy/paste the example code given on trolltech's site (I mean, I transformed it to Python). I made a Dialog with Designer and pyuic4 it (it is named gui.py) : Code:
# -*- coding: utf-8 -*- Code:
#!/usr/bin/python |
Ok, I finally found an answer... I forgot this little line :
Code:
self.highlighter.setDocument(self.textEdit.document()) Hope this will help someone in the future ! |
I actually found out that this was never the problem... I just need to update PyQt4 as I still get stuck in the loop with version 4.4.4. and not with the version I have at work.
Edit : the version I have at work is 4.3.3 so there must be a bug in version 4.4.4. I'm perplex. |
I had an answer to my question on the python usenet group.
If someone has the same problem, here is an answer : http://groups.google.fr/group/comp.l...fc8b120cb5d686 |
All times are GMT -5. The time now is 05:48 PM. |