Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Unsolved JS in QML has incomplete support for XMLHttpRequest

    QML and Qt Quick
    4
    7
    306
    Loading More Posts
    • 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
      Bosh last edited by

      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.Hilk 1 Reply Last reply Reply Quote 0
      • J.Hilk
        J.Hilk Moderators @Bosh last edited by

        @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

        Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


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

        1 Reply Last reply Reply Quote 1
        • B
          Bosh last edited by

          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.Hilk 1 Reply Last reply Reply Quote 0
          • J.Hilk
            J.Hilk Moderators @Bosh last edited by J.Hilk

            @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

            Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


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

            B 1 Reply Last reply Reply Quote 1
            • B
              Bosh @J.Hilk last edited by

              @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。

              fcarney 1 Reply Last reply Reply Quote 0
              • fcarney
                fcarney @Bosh last edited by

                @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 Reply Quote 0
                • M
                  Markus Goetz53 last edited by

                  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 Reply Quote 0
                  • First post
                    Last post