Solved Lost parameter value after call Q_INVOKABLE function from QML.
-
I have a problem of calling Q_INVOKABLE function.
in QML
function doSomeThing(intList, jsonObject) { classItem.someFunction(intList, jsonObject) } ... var arr = [] arr.push(1) arr.push(2) var json = {some data} doSomeThing(arr, json)
in H
... Q_INVOKABLE void doSomethingFunction(QVector<int> intList, QJsonObject object = QJsonObject()); ...
in CPP Class
... void Class::doSomethingFunction(QVector<int> intList, QJsonObject object) { // do some thing with parameters } ...
in CPP part, the parameter int list value had been changed to (0).
I can not understand.
When I include int list to Json, array data is alright, it's fine.
Is anyone has some idea?
thank you.
-
@MintogoDeveloper
your JS array will be converted automatically to a QVariantList wenn passed to c++try that as argument and not a QVector<int> that conversion probably fails
https://doc.qt.io/qt-5/qtqml-cppintegration-data.html#qvariantlist-and-qvariantmap-to-javascript-array-and-object -
@MintogoDeveloper
your JS array will be converted automatically to a QVariantList wenn passed to c++try that as argument and not a QVector<int> that conversion probably fails
https://doc.qt.io/qt-5/qtqml-cppintegration-data.html#qvariantlist-and-qvariantmap-to-javascript-array-and-object -
@J-Hilk Thank you, problem was conversion of data type between QML and Qt(C++).
I resolved it. :)