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. JavaScript with Qt Widget application
Forum Updated to NodeBB v4.3 + New Features

JavaScript with Qt Widget application

Scheduled Pinned Locked Moved QML and Qt Quick
javascriptqtwidgetsqml
10 Posts 3 Posters 5.6k Views 3 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.
  • M Offline
    M Offline
    MTCA
    wrote on last edited by MTCA
    #1

    Is it possible to call javascript function on the event change of ui objects directly, without the help of qml? Most of the tutorials available on internet are based on qml and my aim is to integrate the .ui file directly with .js file.

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

      Hi,

      No you can't, Qt Widgets are C++ based, you need an interpreter to execute JavaScript code

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MTCA
        wrote on last edited by
        #3

        Ohh.. Ok. Thank you so much for your quick reply.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MTCA
          wrote on last edited by
          #4

          While browsing, I came across this example http://doc.qt.io/qt-4.8/qt-script-calculator-example.html in which the javascript function is called directly on arrival of event from ui form.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            It's not called directly, it uses the now deprecated QtScript module that is replaced by the QtQML module

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • M Offline
              M Offline
              MTCA
              wrote on last edited by
              #6

              Great!! Things are getting much clear now. Thank you.

              1 Reply Last reply
              0
              • JKSHJ Offline
                JKSHJ Offline
                JKSH
                Moderators
                wrote on last edited by
                #7

                Hi,

                See QJSEngine. It is inside the Qt QML module, but it is a pure JavaScript engine that doesn't process QML. (It can't import .js files, however -- you need to call evaluate() dirrectly)

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  MTCA
                  wrote on last edited by
                  #8

                  It seems that using QJSEngine, we can directly evaluate the js function. Then how it is different from QScriptEngine? And why it has been deprecated?

                  JKSHJ 1 Reply Last reply
                  0
                  • M MTCA

                    It seems that using QJSEngine, we can directly evaluate the js function. Then how it is different from QScriptEngine? And why it has been deprecated?

                    JKSHJ Offline
                    JKSHJ Offline
                    JKSH
                    Moderators
                    wrote on last edited by
                    #9

                    @MTCA said:

                    how it is different from QScriptEngine? And why it has been deprecated?

                    Internally, Qt Script uses the JavaScriptCore engine. It is old, its performance is not very good, and it is not 100% compliant with the ECMA standard.

                    Qt engineers tried to make Qt Script switch from JavaScriptCore to Google's V8 engine. Unfortunately, this task was not feasible (see https://wiki.qt.io/Qt_Script_V8_Port ).

                    Now, it is expensive for Qt engineers to keep maintaining Qt Script. If they spend time on Qt Script, that means they have less time to fix bugs and add features to other modules. So, they want to deprecate Qt Script and use the new QJSEngine. QJSEngine has better integration with C++ (and QML), and is more compliant with ECMA standards.

                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      MTCA
                      wrote on last edited by
                      #10

                      Ohh. Sounds great!! Thank you for adding some new things in my knowledge base. :)

                      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