Pass QObject to Python in QVariant?
Dynamic Python binding for Qt Applications
Brought to you by:
florianlink,
marcusbarann
If I want to pass a QObject derived class to Python via PythonQtObjectPtr::call(…), how do I do it?
PythonQtObjectPtr::call takes a list of QVariants… but I don't see how to convert a QObject to a QVariant…?
The web page http://pythonqt.sourceforge.net/Features.html says "Convenient conversions to/from QVariant for PythonQtObjectPtr" but I don't see how to do it.
Any suggestions?
QObject* can be transported by QVariant, as follows:
QObject* yourObjectPtr = whateverObjectPtr;
QVariant arg = qVariantFromValue<QObject*>(yourObjectPtr)
QVariantList args;
args << arg;
For details, google for qVariantFromValue or QVariant::fromValue.