QJSEngine passing arguments back to c++
-
Is it possible to pass and JavaScript c++ proxy qobject method back to to c++ as reference or value, i Just can pass when the c++ method recives a Pointer as aargument.
I try to register a meyatype converter but it as no efect in JavaScript enviroment.I Just can pass when a i create create a c++ classe with a method that returns *this as a datatype.
It was Nice to to catch the console log, like a connect signal instande of creating a custom object for that prupose.
My goal is to BE able to create a qsize or a qicon or other type of data with create new in JavaScript and pass to c++ as reference or value.
Tanks Ricardo Matos
-
@Ricardo-MAtos
values from JS to C++ can be handled with the QJSValue type on the C++ side.
But the JS side will never support more types than the engine provides.
Also see this: https://doc.qt.io/qt-5/qtqml-cppintegration-data.html -
@raven-worx
But can pass a c++ type back to c++ like a QIcon or a QSize if inside my c++ classe i have a invokable method that returns *this.
Calling that method from JavaScript and passing to c++ i can have back the QIcon or QSize.
Is it nota possÃvel to create a qmetatype converter for that class?
I read someware that it was possble to use register meta type converter in old versions of qt but i tryit on Qt 6.2 and is nota working.
Im doing something wrong? -
It was Nice to be able to register a meyatype converter and the QJSEngine convert for that object to a data type.
Until now i create a class of QIcon and add and invokable method that returns *this.
Like that i can recive on c++ a QIcon as reference
Is there something that Im missing?
If i create a object in c++ with QJSEngine::toScriptVale of a QIcon it works as well but like that i canto create a new object of that type and if i Change the value it chances for all c++ calls, in JavaScript is nota trivial to clone a object it was Nice to be able to clone it and fonte destroy the Last calls.