On Tuesday 14 August 2007 8:47 am, Diez B. Roggisch wrote:
> Giovanni Bajo schrieb:
> > On 12/08/2007 16.20, Diez B. Roggisch wrote:
> >> Any suggestions? Am I doing something fundamentally wrong wrt
> >> implementation of C++-interfaces?
> >
> > Please post a minimal, complete example that reproduces your problem.
> > Otherwise, it's a little hard to help you...
>
> I know... So I tried to come up with a smaller example. However, it's
> not showing the same, but another problem. Until that is fixed, I think
> investigating the old problem is pretty much useless.
>
> The attached project tries to model the situation I have in my real app.
> It compiles & runs under my Mac.
>
> 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.
>
> 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.
>
> How do I achieve that?
>
> I'm not sure if the two problems are related - but until this works,
> it's moot to try and make the other problem go away.
Do as Jim said and make sure the declaration of IEventReceiver::OnEvent() is
the same in the .h and .sip files (see attached).
Also remove the /Abstract/ annotation (for your example at least). Including
it means that "there are *other* abstract functions which I'm not going to
tell you about".
With the new .sip file I get the following output from running your test...
overloaded event: 200
overloaded event: 100
Phil
// Define the SIP wrapper to the irrlicht library
%Module siptest 0
// TODO: figure out
// if there is a way to only include that
// in the enum source
%ModuleHeaderCode
#include <test.h>
%End
class IEventReceiver {
public:
virtual void OnEvent(int) = 0;
};
class PyIEventReceiver : IEventReceiver {
public:
void OnEvent(int);
};
class IEventReceiverTest {
public:
void test();
void setReceiver(IEventReceiver *);
};
_______________________________________________
PyQt mailing list [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt