[PyKDE] QSyntaxHighlighter issues

Eli Yukelzon reflog at gmail.com
Sat Sep 25 12:00:04 BST 2004


Hi there.
I'm trying to implement a HTML tag highlighting in QTextEdit
I've subclassed the QSyntaxHighlighter and QTextEdit like this:

class qh(QSyntaxHighlighter):
	def __init__(self, edit):
		QSyntaxHighlighter(edit)

	def highlightParagraph( text, lastPara ):
		regexp = re.compile( r'^([\\w-]+:\\s)')
		if( regexp.search( text ) != -1 ):
			font = textEdit().currentFont()
			font.setBold( True )
			self.setFormat( 0, regexp.matchedLength(), font )
		
		return 0

class te(QTextEdit):
	def __init__ (self,parent = 0, name = ""): 
		QTextEdit(parent,name)
		#self.setTextFormat( Qt.PlainText )
		self.sh = qh(self)

but on startup i get this exception:
attributeError, sipThis 
in QSyntaxHighlighter constructor.

What am i doing wrong? Maybe someone already implemented this, and I'm
just reinventing the wheel?
-- 
To err is human, to really screw things up - you need a computer.




More information about the PyQt mailing list