How To Call A Non-parameterised Qml Function From C++
I am trying to call a function in my QML: function resetSomething() { tempVar= undefined } I am not sure how to write the invokeMethod for this function. I tried using somethi
Solution 1:
As you can see in your error message Qt's Meta Object System is trying to find method resetSomething(QVariant), but your method doesn't have any parameters. I guess it's because of wrong Q_RETURN_ARG macro usage. Seems that you can simply fix it like this:
QVariant returnArg;
QMetaObject::invokeMethod(qObj, "resetSomething", Qt::DirectConnection,
Q_RETURN_ARG(QVariant, returnArg));
Also I suggest you to read official Qt documentation, it is brilliant.
BTW: Nice repo from Google with a lot of C++/JavaScript intercommunication. You can find a lot of useful patterns there.
Post a Comment for "How To Call A Non-parameterised Qml Function From C++"