QVariant and PythonQtObjectPtr

Alan Ezust
2008-08-26
2013-04-06
  • Alan Ezust

    Alan Ezust - 2008-08-26

    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?

     
  • tangming

    tangming - 2010-10-22

    this example maybe helpful.

    QVariant v;
    MyCustomStruct c;
    c=v.value<MyCustomStruct >();

     
  • Zvi Tarem

    Zvi Tarem - 2012-08-25

    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.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks