JS in QML has incomplete support for XMLHttpRequest
-
I want to download file using XMLHttpRequest in QML and want to konw the progress. The
code show as belowfunction 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 -
I want to download file using XMLHttpRequest in QML and want to konw the progress. The
code show as belowfunction 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@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 -
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.
-
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.
-
@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.
-
@J-Hilk
Thanks!
Maybe for this reason as above, but the QML compiler does not report an error or wanning。@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.
-
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