Important: Please read the Qt Code of Conduct -

Object transfer from javascript to c++

  • Hi,
    I know how to "expose C++ method to JavaScript in QML": and data conversion will happen when parameters passing.So JavaScript objects will be convert to QVariantMap when used as C++ method parameters.

    (1)But question is here, as I interpret, every time a new QVariantMap will be create as the parameter, how could we identify the object as in JavaScript where "===" could be used? Does Qt provide the way to do such thing?

    (2)And what's more:
    if we have a method "int foo(QVariantMap obj)" in C++, then we call it in JavaScript like this:, how can we modify the attributes of JSObj in C++.
    As far as I know, we should "create a component object in c++": ,and then call QMetaObject::invokeMethod to invoke JavaScript method in which we can change the JSObj attributes.Is there other way?

    (3)What I also concern is the performance of creating a new QVariantMap of JSObj every time calling c++ method in JavaScript.

    I need help, thanks for replying.

Log in to reply