I was wondering, all of the call() methods that i see in PythonQt and PythonQtObjectPtr return QVariant. Do I need to go into the <Python.h> interface to get a PyObject* and then wrap that in a PythonQtObjectPtr? Or is there a way to get a reference to an object returned by a callable from PythonQt?
Or is there a way to convert the returned QVariant into a PythonQtObjectPtr?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
One of the constructors of PythonQtObjectPtr takes a QVariant, and if that holds a PyObject*, the PythonQtObjectPtr takes ownership of it. So you can simply write:
PythonQtObjectPtr result = module.call("func", …);
'result' is a wrapped Python object, so you can do: result.getVariable(), result.call(), etc.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I was wondering, all of the call() methods that i see in PythonQt and PythonQtObjectPtr return QVariant. Do I need to go into the <Python.h> interface to get a PyObject* and then wrap that in a PythonQtObjectPtr? Or is there a way to get a reference to an object returned by a callable from PythonQt?
Or is there a way to convert the returned QVariant into a PythonQtObjectPtr?
this example maybe helpful.
QVariant v;
MyCustomStruct c;
c=v.value<MyCustomStruct >();
One of the constructors of PythonQtObjectPtr takes a QVariant, and if that holds a PyObject*, the PythonQtObjectPtr takes ownership of it. So you can simply write:
PythonQtObjectPtr result = module.call("func", …);
'result' is a wrapped Python object, so you can do: result.getVariable(), result.call(), etc.