Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

Qml variant to custom QtObject

$
0
0
I have 2 different C++ objects using Q_PROPERTY and Q_INVOKABLE for a function, in my qml file I have this: include MyObject 1.0  //from c++ incluce MyInvokable 1.0 //from c++     property variant myVariant     MyObject{       id:myObject  }    MyInvokable{     id: myInvokable }   onCallFunction:{     myVariant = myObject;     myInvocable.invokableFunction( myVariant ) } At MyInvokable function I can’t get the value of MyObject: void MyInvocable::invocableFunction(QVariant variant) {      MyObject myObject = qvariant_cast<MyObject>(variant) ; //cant convert to MyObject      qDebug() << "foo: " << myObject.foo(); } MyObject has the macro Q_DECLARE_METATYPE(MyObject); How can I convert QVariant to my custom Object ? Regards

Viewing all articles
Browse latest Browse all 4972

Trending Articles