Forums

OverviewV-Play 2 Support (Qt 5) › My Model can't show rest of the data?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #18808

    Niyazi

    Hi,

    My json’ gets 6 data always. But, I can show only first data. I am not be able to show rest of the data.

    Somewhere in my code something is missing. How do I show all the data in qml? Any help please?

     

    import VPlayApps 1.0
    import VPlay 2.0
    import QtQuick 2.9
    import QtQuick.Layouts 1.3
    
    import "../singletons"
    
    Item {
        id: myWeatherItem
        anchors.horizontalCenter: parent.horizontalCenter
        width: CbStyle.appWidth - 25
        height:  CbStyle.appHeight * 0.27
        anchors.leftMargin: dp(5)
        anchors.rightMargin: dp(5)
    
        AppListView {
            id: weatherView
            anchors.fill: parent
            backgroundColor: "#00000000"
            model: ListModel { id: modelData }
            delegate: Item {
                id: myDelegate
                width: Math.max(110, myWeatherItem.width / weatherView.count)
                height: myWeatherItem.height
    
                // Content
                ColumnLayout {
                    anchors.fill: parent
                    anchors.topMargin: 10
                    anchors.bottomMargin: 10
    
                    // day
                    Text {
                        Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
                        text:  model.day
                    }
    
                    // icon
                    Image {
                        Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
                        scale: 0.75
                        source: model.iconText
                    }
    
                    // temperature
                    Text {
                        Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
                        text: "%1˚C".arg(model.temperature)
                    }
    
                    // seperator
                    Rectangle {
                        anchors.verticalCenter: parent.verticalCenter
                        anchors.right: parent.right
                        width: 1
                        height: (myWeatherItem.height * 0.75)
                        color: "lightgrey"
                        // visible: model.index < weatherView.count - 1
                    }
                } // Contents
            } // delegate: Item
    
    
            Component.onCompleted: {
                var request = new XMLHttpRequest();
                request.open('GET', "https://query.*****************************", true);
                request.onreadystatechange = function() {
                    if (request.readyState === XMLHttpRequest.DONE) {
                        if (request.status && request.status === 200) {
                            var result = JSON.parse(request.responseText)
                            var list = result.query.results.channel.item.forecast //result[0]["forecast"];
                            for(var i in list) {
                                var getStatusIcon = list[i].code
                                modelData.append({ "day": list[i].day,
                                                 "iconText": "../../assets/weather/" + getStatusIcon + ".png",
                                                 "temperature": list[i].high
                                             });
                                console.log(i + ", Day:" + list[i].day + ", Temp:" + list[i].high + ", CurrentIconSet: " + getStatusIcon)
                                getStatusIcon = ""
                            } // for
                        }
                        else {
                            console.log("WeatherLog:", request.status, request.statusText)
                        }
                    } // if (request.readyState
                } // function
                request.send();
            }
    
        } // WeatherWidget
    } // myWeatherItem
    

     

    #18818

    Günther
    V-Play Team
    #18820

    Niyazi

    :) Thank you. I will post full code later with a new post

Viewing 3 posts - 1 through 3 (of 3 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support