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

r nbs.public at gmail.com
Sun Feb 8 17:31:08 GMT 2009


On Sun, Jan 6, 2008 at 7:49 PM, David Boddie <david at boddie.org.uk> wrote:
> On Sun Jan 6 18:23:39 GMT 2008, Aaron Digulla wrote:
>
>> I tried to overload insertText() of QTextCursor like this:

Sorry for digging out this old thread. I've just hit the same problem.

>> 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.

Is it a limitation of PyQt bindings or Qt itself? Is there any
workaround available (at PyQt level or above)?

I can't believe this to be a dead end situation - what's the point of
having a mechanism for switching the cursor if there is no way to
modify it? This seems to be a pretty general issue, potentially
affecting many other Qt classes as well.

As Aaron has pointed out, an alternative would be to rewrite the whole
event handling procedure, which is hardly a solution.

Regards,
-r


More information about the PyQt mailing list