Display image from xmlhttprequest, only with qml

292 views Asked by At

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

                }
            }
        }
    }
}
0

There are 0 answers