On Tue, Nov 8, 2011 at 11:07 AM, Alexander A. Prokhorov <prok...@gmail.com> wrote: > Dear colleagues, > > I am suffering of the lack of one feature, possibly there is someone who can > help. > We use PySide in development C++/Python hybrid application. At the moment we > would like to do the following. > > We have generated PySide bindings for our application core (we call it > engine) to make it available from Python scripts which we run inside > embedded Python interpreter. It works fine. At the moment I want to inherit > new python class from parent implemented in C++, construct object of this > class in python and get pointer to it (as pointer to base class) on C++ > layer. > > For instance in C++ I have: > class Base { > public: > void method(); > }; > > in Python script: > > # import PySide generated bindings > import py_engine > > class Child(py_engine.Base): > def method(self): > """overwrite base class method""" > print 'blabla' > pass > > def create_child(): > return Child() > > So in this case I would like to create python object and make it available > in C++ layer as Base*. > > How would you recommend to achieve this?
I think I'm not understanding your question. When you have a c++ method/function that expects a Base* and you pass a Base (or child of Base) Python object to it shiboken (the generator) converts it to the proper pointer type. This happens everywhere on Qt, with QObject and QWidget (the main base classes). Also remember that only virtual methods are overrideable. (Base::method isn't a virtual in the snippet above). -- Lauro Moura INdT - Instituto Nokia de Tecnologia _______________________________________________ PySide mailing list PySide@lists.pyside.org http://lists.pyside.org/listinfo/pyside