0

I am creating a qml only app for Ubuntu Touch and made a xmlhttprequest, where the response is an image in png. I can receive the image as a BLOB i think, but how can I display this now only with QML? I have no C++, Python or anything else. There is no FileReader available in QML's javascript!

Image {
    id: img
    anchors.fill: parent

    Component.onCompleted: {

        http.open( type, requestUrl, true);
        http.setRequestHeader('Content-type', 'application/json; charset=utf-8')
        http.timeout = defaultTimeout

        http.onreadystatechange = function() {
            if (http.readyState === XMLHttpRequest.DONE) {
                var responseType = http.getResponseHeader("Content-Type")
                if ( responseType = "image/png" ) {
                    var imageBlob = http.responseText

                    // This does not work ...
                    img.source = imageBlob

                }
            }
        }
    }
}
Krille
  • 1
  • That's impossible. You should either do that using [QQuickImageProvider](http://doc.qt.io/qt-5/qquickimageprovider.html) (C++ extension) or receive URL instead of image bytes. – folibis May 19 '18 at 13:41
  • Can you control the image's response header? Just make it a regular image instead of a blob and then specify the URL in the source.. – mike510a May 20 '18 at 02:24

0 Answers0