Calling a wrapped QObject method (slot) from a CPython module
Dynamic Python binding for Qt Applications
Brought to you by:
florianlink,
marcusbarann
Hi,
I have a QObject derived class with a slot declared:
When I add my object into the python interpreter with addObject() I can see the object and its method foo() from the PythonQt console. So far awesome! If do obj.foo.parameterTypes() I get back (('int', void*),) also great.
Now I'm struggling trying to call this method with PyObject_CallMethod() from inside a c++ python module. I can't figure out the right thing to pass in for the void* argument.
I could change the data argument to something else if that would simplify things. I just need to pass a pointer and I don't want to use strings because I don't want to make copies which I think PyObject_CallMethod will do if I use the "s#" conversion format.
ta
- James
AneasierwaytocallAn easier way to call Python objects from C++ is to use a
PythonQtObjectPtr
to wrap the Python object. Then you can simply use the call() method.
Regarding the void argument, this is currently not supported,
you can either use char or QString or QByteArray (or a pointer to a known object).
Thanks!
Yes, the call() thing is great, I'm already making use of that elsewhere. I can't use that though in this situation though as I don't want the C module that I'm calling from depending on PythonQt.
Passing void* is icky anyway I guess so I'm going to restructure the problem.
This is a really cool library!
Cheers,
James