How to access JSON web services from QML

  • Translated from Spanish with Google

    I would like to know what is needed to access JSON web data, specifically to the API of
    Community Radio Browser:

    For example, this call:

    Until now I had the following example of access to the Flickr API of the book Qt 5 Cadaques (, but it does not work for other services:

    import QtQuick 2.5

    Rectangle {
    width: 320
    height: 480
    ListView {
    id: view
    anchors.fill: parent
    delegate: Thumbnail {
    width: view.width
    text: modelData.title

    function request() {
        var xhr = new XMLHttpRequest();
        xhr.onreadystatechange = function() {
            if (xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
            } else if(xhr.readyState === XMLHttpRequest.DONE) {
                var json = JSON.parse(xhr.responseText.toString())
                view.model = json.items
        }"GET", "");
    Component.onCompleted: {


    Does it depend on whether the JSON response returns a callback or not?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.