Important: Please read the Qt Code of Conduct -

Json array and qml

  • Hi. I have a little problem. This is the Json:

    @{"therainman":{"id":166365,"name":"The Rain Man","profileIconId":642,"summonerLevel":30,"revisionDate":1394650685000}}@

    Is a example. The name "therainman" changes when i request another nickname. If i request therainman, the server send to me this json. If i request, for example, c9meteos, changes everything and they send me another thing.

    Now, this is the code:

    @ TextInput {
    id: textInput1
    x: 147
    y: 42
    width: 80
    height: 20
    text: qsTr("Text Input")
    font.pixelSize: 12
    focus: true
    Keys.onPressed: {
    if (event.key == Qt.Key_Return){

    function request(a) {
        var xhr = new XMLHttpRequest();
        xhr.onreadystatechange = function() {
            if (xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
            } else if(xhr.readyState === XMLHttpRequest.DONE) {
                var obj = JSON.parse(xhr.responseText.toString());
        }"GET", ""+a+"?api_key=<api_key>");

    The problem is here:


    This just not work. If i set print(, it works. But this is a value that changes to whatever i want in a textinput, so i can't put this. I don't know how to declare this.

    Thanks and sorry for my english!

Log in to reply