[PyQt] sip reimplemented protected function

Matt Newell newellm at blur.com
Thu Jan 16 16:29:40 GMT 2014


I have a sip wrapped class HtmlHighlighter that inherits from 
QSyntaxHighlighter, and it won't compile giving the error:

/usr/share/sip/PyQt4/QtGui/qsyntaxhighlighter.sip: In function ‘PyObject* 
meth_HtmlHighlighter_setCurrentBlockUserData(PyObject*, PyObject*, 
PyObject*)’:
/usr/share/sip/PyQt4/QtGui/qsyntaxhighlighter.sip:78:77: error: 
‘qtgui_wrap_ancestors’ was not declared in this scope
             PyObject *py_td = qtgui_wrap_ancestors(td, 
sipType_QTextDocument);
                      
First of all if QSyntaxHighlighter is already wrapped in PyQt[45], I would 
think a subclass should not need to have the non-virtual protected methods 
reimplemented to be accessible at the python level.  It should be safe to let 
python call meth_QSyntaxHighlighter_setCurrentBlockUserData, which will call 
sipQSyntaxHighlighter's version.  I realize that sipHtmlHighlighter won't be a 
subclass of sipQSyntaxHighlighter, but that shouldn't actually matter in this 
case.  This may even be the case for virtual function, but I'm not sure.

Second, I think there should be a class annotation specifying that the wrapped 
class doesn't need access to the protected functions.

Thanks,
Matt




More information about the PyQt mailing list