[PyQt] Is it possible to override/extend QTextCursor?

David Boddie david at boddie.org.uk
Sun Jan 6 19:49:45 GMT 2008

On Sun Jan 6 18:23:39 GMT 2008, Aaron Digulla wrote:

> I tried to overload insertText() of QTextCursor like this:


> but this test only outputs "x". I've checked the C++ source of Qt4 and
> it should call at least the methods defined above.
> I'm using openSUSE Linux and python-qt4 4.3-19. The methods are defined
> in qtextcursor.sip, only insertText() is confusing:
>     void insertText(const QString &text);
>     void insertText(const QString &text, const QTextCharFormat &format);
> Which one will Python overload?

Neither, unfortunately.

> Any ideas what could be wrong?

Neither of those functions are virtual in Qt. This means that Qt will always
call the original QTextCursor::insertText() versions in preference to your
version, though you should be able to call your implementation from Python.


More information about the PyQt mailing list