[PyKDE] QSyntaxHighlighter issues

stuff at mailzilla.net stuff at mailzilla.net
Sat Sep 25 14:51:26 BST 2004


Try passing "self" into the constructor of the base class (ie. __init__ 
method) in the constructor of your derived classes. 

Change this:
        QSyntaxHighlighter(edit)
to:
        QSyntaxHighlighter.__init__(self, edit)

and:
        QTextEdit(parent,name)
to:
        QTextEdit.__init__(self, parent,name)

Hope this helps,

Phil Schwartz

On Sat, 25 Sep 2004, Eli Yukelzon wrote:

> 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 QSyntaxHighlighter(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?
> 





More information about the PyQt mailing list