Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Object transfer from javascript to c++
Forum Updated to NodeBB v4.3 + New Features

Object transfer from javascript to c++

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 724 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wade-J
    wrote on last edited by
    #1

    Hi,
    I know how to "expose C++ method to JavaScript in QML":http://qt-project.org/doc/qt-5/qtqml-cppintegration-exposecppattributes.html 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: CObj.foo(JSObj), how can we modify the attributes of JSObj in C++.
    As far as I know, we should "create a component object in c++":http://qt-project.org/doc/qt-5/qtqml-cppintegration-interactqmlfromcpp.html ,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.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved