Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QJSEngine passing arguments back to c++
QtWS25 Last Chance

QJSEngine passing arguments back to c++

Scheduled Pinned Locked Moved General and Desktop
javascriptqjsengine
4 Posts 2 Posters 582 Views
  • 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.
  • R Offline
    R Offline
    Ricardo MAtos
    wrote on 9 Jul 2021, 22:18 last edited by
    #1

    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

    R 1 Reply Last reply 9 Jul 2021, 22:23
    0
    • R Ricardo MAtos
      9 Jul 2021, 22:18

      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

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 9 Jul 2021, 22:23 last edited by
      #2

      @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

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      R 1 Reply Last reply 9 Jul 2021, 22:34
      1
      • R raven-worx
        9 Jul 2021, 22:23

        @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

        R Offline
        R Offline
        Ricardo MAtos
        wrote on 9 Jul 2021, 22:34 last edited by
        #3

        @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?

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Ricardo MAtos
          wrote on 9 Jul 2021, 23:06 last edited by
          #4

          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.

          1 Reply Last reply
          0

          4/4

          9 Jul 2021, 23:06

          • Login

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