how to convert js array to c++ vector?[solved]
-
wrote on 17 May 2015, 09:56 last edited by LeaA
hi,
I want to invoke a c++ function from a js function and I want that the c++ function will get the array that was declared in the js file..
there is anybody who know how can I do it?thanks!
-
hi,
I want to invoke a c++ function from a js function and I want that the c++ function will get the array that was declared in the js file..
there is anybody who know how can I do it?thanks!
Hi @LeaA,
UseQVariantList
on C++ side. Eg:// JavaScript side: var cars = ["Saab", "Volvo", "BMW"]; obj.getJsArray(cars) // getJsArray is a Q_INVOKABLE function on C++ side //C++ side void MyClass::getJsArray(QVariantList list) { qDebug() << list; //Use toVector() to convert it to vector }
-
wrote on 17 May 2015, 12:37 last edited by
thank you!
1/3