[PyQt] problem with abstract classes
Giovanni Bajo
rasky at develer.com
Tue Aug 14 14:24:59 BST 2007
On 14/08/2007 9.47, Diez B. Roggisch wrote:
> Essentially all I try to do is to create a interface in C++
> (IEventReceiver), a subclass (PyIEventReceiver) to overload the pure
> virtual methods of the base-interface so it can be overloaded in python
> and a test-class that invokes the OnEvent-method in a previously set
> IEventReceiver implementation.
You don't need PyIEventReceiver at all. You can directly subclass
IEventReceiver, if that's what you want to achieve.
/Abstract/ is meant to force SIP *NOT* to allow instantiations of the class.
That's not what you want.
> Then in the python-test-script, I try and instantiate the test-object,
> and subclass the PyIEventReceiver. The latter is the problem. When
> passing that into the test-object and invoke the test-method, I don't
> get the overloaded method invoked.
You didn't define them as "virtual" in the sip file... what did you expect? :)
Define them as "virtual" (and even add the "= 0" where appropriate) and you
will get the right behaviour.
--
Giovanni Bajo
More information about the PyQt
mailing list