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. JS in QML has incomplete support for XMLHttpRequest
Forum Update on Monday, May 27th 2025

JS in QML has incomplete support for XMLHttpRequest

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 4 Posters 687 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.
  • B Offline
    B Offline
    Bosh
    wrote on 17 Jul 2020, 09:06 last edited by
    #1

    I want to download file using XMLHttpRequest in QML and want to konw the progress. The
    code show as below

    function request_load(url) {
            let xhr = new XMLHttpRequest();
            xhr.onprogress = function () {
                console.log("LOADING", xhr.status);
            };
            xhr.open("GET", url, true);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
                    console.log("HEADERS_RECEIVED");
                } else if (xhr.readyState === XMLHttpRequest.DONE) {
                    console.log("DONE");
    
                }
            };
            xhr.send();
        }
    

    But xhr.onprogress event do nothing.
    I try it on Chrome Console. It's right

    J 1 Reply Last reply 17 Jul 2020, 09:14
    0
    • B Bosh
      17 Jul 2020, 09:06

      I want to download file using XMLHttpRequest in QML and want to konw the progress. The
      code show as below

      function request_load(url) {
              let xhr = new XMLHttpRequest();
              xhr.onprogress = function () {
                  console.log("LOADING", xhr.status);
              };
              xhr.open("GET", url, true);
              xhr.onreadystatechange = function () {
                  if (xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
                      console.log("HEADERS_RECEIVED");
                  } else if (xhr.readyState === XMLHttpRequest.DONE) {
                      console.log("DONE");
      
                  }
              };
              xhr.send();
          }
      

      But xhr.onprogress event do nothing.
      I try it on Chrome Console. It's right

      J Offline
      J Offline
      J.Hilk
      Moderators
      wrote on 17 Jul 2020, 09:14 last edited by
      #2

      @Bosh QML supports ECMA-262 7th edition standard

      You'll have to check if what you're trying to do is a feature from a newer standard!
      https://doc.qt.io/qt-5/qtqml-javascript-hostenvironment.html


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      1
      • B Offline
        B Offline
        Bosh
        wrote on 17 Jul 2020, 09:25 last edited by
        #3

        In this page, doc show the XMLHttpRequest
        https://doc.qt.io/qt-5/qtqml-javascript-qmlglobalobject.html#xmlhttprequest. --- "The XMLHttpRequest API implements the same W3C standard as many popular web browsers "

        In w3c, this page show the onprogress event.

        J 1 Reply Last reply 17 Jul 2020, 09:26
        0
        • B Bosh
          17 Jul 2020, 09:25

          In this page, doc show the XMLHttpRequest
          https://doc.qt.io/qt-5/qtqml-javascript-qmlglobalobject.html#xmlhttprequest. --- "The XMLHttpRequest API implements the same W3C standard as many popular web browsers "

          In w3c, this page show the onprogress event.

          J Offline
          J Offline
          J.Hilk
          Moderators
          wrote on 17 Jul 2020, 09:26 last edited by J.Hilk
          #4

          @Bosh literally the next sentence:

          Additionally, the responseXML XML DOM tree currently supported by QML is a reduced subset of the DOM Level 3 Core API supported in a web browser.


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          B 1 Reply Last reply 17 Jul 2020, 09:35
          1
          • J J.Hilk
            17 Jul 2020, 09:26

            @Bosh literally the next sentence:

            Additionally, the responseXML XML DOM tree currently supported by QML is a reduced subset of the DOM Level 3 Core API supported in a web browser.

            B Offline
            B Offline
            Bosh
            wrote on 17 Jul 2020, 09:35 last edited by
            #5

            @J-Hilk
            Thanks!
            8c30a6e4-7e92-4a56-a4f6-92f8101c2650-image.png
            Maybe for this reason as above, but the QML compiler does not report an error or wanning。

            F 1 Reply Last reply 17 Jul 2020, 17:00
            0
            • B Bosh
              17 Jul 2020, 09:35

              @J-Hilk
              Thanks!
              8c30a6e4-7e92-4a56-a4f6-92f8101c2650-image.png
              Maybe for this reason as above, but the QML compiler does not report an error or wanning。

              F Offline
              F Offline
              fcarney
              wrote on 17 Jul 2020, 17:00 last edited by
              #6

              @Bosh Submit a bug/feature report: https://bugreports.qt.io I looked at the source code and I don't see the term progress in any of the files I looked at. My guess is it has not been implemented yet.

              As for no error/warning is my guess it just looks like you set a property on an object. There would be no warning/error for an unused value.

              Also note that while QML strives to create a nice environment for scripting UI elements it does not strive for browser compliance. QML is not a browser. So QML supports what their devs choose to support.

              C++ is a perfectly valid school of magic.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Markus Goetz53
                wrote on 24 Aug 2020, 13:31 last edited by
                #7

                Might be this existing bug: https://bugreports.qt.io/browse/QTBUG-67337?jql=text ~ "xmlhttprequest progress"

                Indeed nothing in code: https://code.woboq.org/qt5/qtdeclarative/src/qml/qml/qqmlxmlhttprequest.cpp.html

                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