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. QScript / QJSEngine / QQmlEngine... which is best suitable to add scripting to an application
QtWS25 Last Chance

QScript / QJSEngine / QQmlEngine... which is best suitable to add scripting to an application

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 2 Posters 1.4k 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.
  • T Offline
    T Offline
    TheCrowKaka
    wrote on last edited by
    #1

    I already have an application written in Qt C++. I am looking at creating a feature of running scripts from my application whereby users could respond to signals, get different values and execute methods in my C++ application without me required to make any changes to the compiled application.
    This scripting could be both non GUI based computing or GUI based customised display of values and user inputs or could also involve getting data from Databases on the PC or in network and passing the data to the application for processing. Or it could involve getting data over Serial Port and passing the data to the application for processing.

    I am confused on which of these 3 methods to choose from. QScript i understand is now depreciated and not recommended for new applications. (Am I correct here?)

    A Qt Enthusiastic...

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Yes QScript is deprecated but most feature full. like it has debugger widget.
      QJSEngine is the new replacement and should do the job.
      QQmlEngine is the base of QML but could allow for users to also add interfaces
      and other fancy stuff. Might be overkill for this use case.

      T 1 Reply Last reply
      2
      • mrjjM mrjj

        Hi
        Yes QScript is deprecated but most feature full. like it has debugger widget.
        QJSEngine is the new replacement and should do the job.
        QQmlEngine is the base of QML but could allow for users to also add interfaces
        and other fancy stuff. Might be overkill for this use case.

        T Offline
        T Offline
        TheCrowKaka
        wrote on last edited by
        #3

        @mrjj
        So what is your opinion. Should I still use QScript?
        Can you direct me to some exhaustive document or tutorial on using QScript properly?

        And also the documentation for QJSEngine if that is recommended and capable of running even a GUI independent of QWidget application.

        A Qt Enthusiastic...

        mrjjM 1 Reply Last reply
        0
        • T TheCrowKaka

          @mrjj
          So what is your opinion. Should I still use QScript?
          Can you direct me to some exhaustive document or tutorial on using QScript properly?

          And also the documentation for QJSEngine if that is recommended and capable of running even a GUI independent of QWidget application.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          @TheCrowKaka
          Well its hard question. I found QScript somewhat more mature but
          QJSEngine will be around for many years and some day, QScript will stop being
          bundled and you need to compile it yourself etc.
          So if a user debugger etc is not really needed, the favour shifts to QJSEngine, in my book.
          So for a mini script thing, i would go with QJSEngine. I think it can run gui less but i have never tried it.

          Sadly, i never found really good tuts on it. Mostly using the docs.

          T 1 Reply Last reply
          2
          • mrjjM mrjj

            @TheCrowKaka
            Well its hard question. I found QScript somewhat more mature but
            QJSEngine will be around for many years and some day, QScript will stop being
            bundled and you need to compile it yourself etc.
            So if a user debugger etc is not really needed, the favour shifts to QJSEngine, in my book.
            So for a mini script thing, i would go with QJSEngine. I think it can run gui less but i have never tried it.

            Sadly, i never found really good tuts on it. Mostly using the docs.

            T Offline
            T Offline
            TheCrowKaka
            wrote on last edited by
            #5

            @mrjj
            Absence of good tuts is a really bad thing.

            I dont know if there will be requirement of mini script or mega script.
            My idea of introducing the scripting option is to ensure that the core application is not required to be changed for any further additions. If the user is given the freedom to do, they will want to do many complex things and then the scripting engine which I standardize for my application should have the capability to accomplish that.
            A simple use case could be like this.
            While my application which has its GUI is running in the background, that application executes a script. That script has an independent window where a data from a CSV file or database is read and presented to the user. The user selects the record to be passed to the main application and once he presses a button, this selected data is sent to the application for processing.
            Here, I already have a application running the main thread and need to start the UI programmed in the script like a dialog and once that task is finished, terminate the script.
            I did not evaluate QScript, but I thought maybe QQmlEngine and the qml and js languages used for scripting might work better. I got this idea from this video on Youtube from the QtWS15
            https://www.youtube.com/watch?v=7LsKoVrb8C8

            Even if I want to use that, could not find any thing as a tutorial on doing this properly.

            A Qt Enthusiastic...

            1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              well QQmlEngine would also be a good candidate.

              Starting point could be
              http://doc.qt.io/qt-5/qtjavascript.html

              T 1 Reply Last reply
              0
              • mrjjM mrjj

                well QQmlEngine would also be a good candidate.

                Starting point could be
                http://doc.qt.io/qt-5/qtjavascript.html

                T Offline
                T Offline
                TheCrowKaka
                wrote on last edited by
                #7

                @mrjj
                Thanks for your inputs.
                I will now start investigating the QQmlEngine with QWidgets for scripting.

                A Qt Enthusiastic...

                mrjjM 1 Reply Last reply
                0
                • T TheCrowKaka

                  @mrjj
                  Thanks for your inputs.
                  I will now start investigating the QQmlEngine with QWidgets for scripting.

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @TheCrowKaka
                  Well i think its good road.
                  I think you might need to rearrange your apps classes a bit to allow for
                  reuse as scripting but should be nothing major.

                  T 1 Reply Last reply
                  0
                  • mrjjM mrjj

                    @TheCrowKaka
                    Well i think its good road.
                    I think you might need to rearrange your apps classes a bit to allow for
                    reuse as scripting but should be nothing major.

                    T Offline
                    T Offline
                    TheCrowKaka
                    wrote on last edited by
                    #9

                    @mrjj
                    I think, not just rearranging the classes, I might also have to have a wrapper class to expose only the necessary part of the application for scripting.
                    Thanks for your help. I might be posting many more queries as I investigate this thing.

                    A Qt Enthusiastic...

                    mrjjM 1 Reply Last reply
                    0
                    • T TheCrowKaka

                      @mrjj
                      I think, not just rearranging the classes, I might also have to have a wrapper class to expose only the necessary part of the application for scripting.
                      Thanks for your help. I might be posting many more queries as I investigate this thing.

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @TheCrowKaka
                      yes , you will need to expose it to QML
                      http://doc.qt.io/qt-5/qtqml-cppintegration-topic.html
                      and most likely a more reduced interface for the end user.
                      That of cause depends on what they do need access to .

                      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