C function as QJSValue
Unsolved
Language Bindings
-
Hi there and thx for answering if you can.
In my QJS scripts, I need to call C functions but it is not clear in the doc how to declare such an operation. i.e.
int myfunc(int a, int b); QJSValue myFunction = myEngine.newObject(); myFunction.setProperty("myfunc", myfunction);
then...
Thx again for answering.
-
Hi
You do the same as a c++ function.
https://doc.qt.io/qt-5/qtqml-cppintegration-topic.html
example.
https://forum.qt.io/topic/33170/call-c-function-from-qmlthe c++ function can then call the C function.
-
Hi
I dont think its possible that way you try.https://doc.qt.io/qt-5/qtqml-cppintegration-topic.html
https://doc.qt.io/qt-5/qtqml-cppintegration-overview.html#I dont see any samples of using plain function pointers and its
very doubtful that the JS could just call it any way.Just use the QObject way. Its like 12 lines of code extra.