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. Data exchange between Java Script and Qt C/C++
Forum Updated to NodeBB v4.3 + New Features

Data exchange between Java Script and Qt C/C++

Scheduled Pinned Locked Moved Unsolved General and Desktop
javascriptc++
4 Posts 2 Posters 1.7k 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.
  • B Offline
    B Offline
    Briddl
    wrote on 10 Oct 2016, 06:48 last edited by
    #1

    Hi,

    is there a way to pass data from a JavaScript application to C/C++ Part of Qt and vice versa. I searched a while now and only thing I found out is web or QML related and since I'm new to this part of Qt and I don't really understand it right now.

    What I'm trying to do is the Qt desktop Applikation works as interface to Hardware. And the java Scripts should contain the logic of the different use cases of the hardware. The idea right now is to load the Java Scripts with QJSEngine and Execute them with QJSengine.evaluate().

    Is it possible to use Signal and Slots here when yes how?

    Regards

    B 1 Reply Last reply 10 Oct 2016, 07:32
    0
    • P Offline
      P Offline
      p3c0
      Moderators
      wrote on 10 Oct 2016, 07:26 last edited by
      #2

      @Briddl

      Is it possible to use Signal and Slots here when yes how?

      Yes. But you will have to inject a QObject derived class into QJsEngine as explained here.
      This class will contain signals and slots(Q_INVOKABLE functions or public slots) which will then be accessible from the scripts. As usual you can connect to these signals and slots on the C++ side so that when you emit a signal from the script it will be captured by the slot in C++.

      157

      1 Reply Last reply
      4
      • B Briddl
        10 Oct 2016, 06:48

        Hi,

        is there a way to pass data from a JavaScript application to C/C++ Part of Qt and vice versa. I searched a while now and only thing I found out is web or QML related and since I'm new to this part of Qt and I don't really understand it right now.

        What I'm trying to do is the Qt desktop Applikation works as interface to Hardware. And the java Scripts should contain the logic of the different use cases of the hardware. The idea right now is to load the Java Scripts with QJSEngine and Execute them with QJSengine.evaluate().

        Is it possible to use Signal and Slots here when yes how?

        Regards

        B Offline
        B Offline
        Briddl
        wrote on 10 Oct 2016, 07:32 last edited by
        #3

        @Briddl I found the solution. It seamed I searched in the wrong. It is possible to pass a Object via QJSengine to the JS Environment what will handle the communication.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          p3c0
          Moderators
          wrote on 10 Oct 2016, 08:52 last edited by
          #4

          @Briddl Great!. Btw. why do you want to implement logic in JS ?

          157

          1 Reply Last reply
          0

          1/4

          10 Oct 2016, 06:48

          • Login

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