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 Update on Monday, May 27th 2025

JavaScript with Qt Widget application

Scheduled Pinned Locked Moved QML and Qt Quick
javascriptqtwidgetsqml
10 Posts 3 Posters 5.6k 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.
  • M Offline
    M Offline
    MTCA
    wrote on 20 Jul 2015, 10:00 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
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 20 Jul 2015, 21:37 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 21 Jul 2015, 04:05 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 21 Jul 2015, 11:23 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
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 21 Jul 2015, 11:41 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 21 Jul 2015, 12:14 last edited by
              #6

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

              1 Reply Last reply
              0
              • J Online
                J Online
                JKSH
                Moderators
                wrote on 21 Jul 2015, 12:34 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 23 Jul 2015, 05:02 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?

                  J 1 Reply Last reply 23 Jul 2015, 05:43
                  0
                  • M MTCA
                    23 Jul 2015, 05:02

                    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?

                    J Online
                    J Online
                    JKSH
                    Moderators
                    wrote on 23 Jul 2015, 05:43 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 23 Jul 2015, 07:08 last edited by
                      #10

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

                      1 Reply Last reply
                      0

                      10/10

                      23 Jul 2015, 07:08

                      • Login

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