My app uses QSharedPointers throughout the C++ API, where instead of returning an object, it usually returns a smart pointer to it and every class has an accompanying typedef for convenience.
class SomeClass
{
SomeClassP getInstance() { return SomeClassP(new SomeClass()); }
}
typedef QSharedPointer<SomeClass> SomeClassP;
This has worked well, but I'm wondering how/if my design needs to be altered to handle PythonQt integration. For example, in a PythonQtWrapper what should I return from pointers? If I'm dealing with pointers in python, how can I call other functions that take a smart pointer and not a normal pointer? Do I need to expose the smart pointer to PythonQt? It seems that in boost::python a lot of the smart pointer stuff was taken care of automatically. What needs to be done in my case? Should I add additional functions in C++ that accept non-smart-pointers that simply wrap the pointer in a smart pointer and send it on to the smart-pointer-accepting function? It seems the python API has some fairly complex rules regarding pointer ownership.
class PythonQtWrapper_SomeClass : public QObject
{
Q_OBJECT
public slots:
SomeClass* new_SomeClass() { return new SomeClass(); }
void delete_Mesh(SomeClass* obj) { delete obj; }
SomeClass* static_SomeClass_build(int foo) {
SomeClassP ack = SomeFactory::build(foo);
return ?
}
};