Array length



  • Hi all, I am wilson. May I ask how to calculate array length size.

    I am getting data from Xml file, and I need to get the total length of array size, how could I make it?

    Below is part of my code.

    @XmlListModel {
    id: newsModel
    property string feedUrl: ""
    property bool loading: status == XmlListModel.Loading

        source: "http://ios.eosworld.com.my/android/fws/news.php"
        query: "/plist/array/dict"
    
        XmlRole { name: "date"; query: "string[1]/string()" }
    }
    

    ListView {
    id: list
    anchors {
    left: parent.left
    right: parent.right
    top: headBar.bottom
    bottom: parent.bottom
    }
    clip: true
    model: newsModel
    delegate: listDelegate
    }

        Component {
            id: listDelegate
            LatestNewsItem
            {
                text1:date
            }
    

    }
    }
    @

    I would like to get total date I will get?
    Thank You for helping..



  • Hi wilson,
    What your mean about the array length, is that count of model?



  • yes. I think..I would like to calculate how many data in xml file.



  • Add these code to XmlListModel:
    @onStatusChanged: {
    if (status == XmlListModel.Ready) {
    if (count > 0) {
    console.log("Total = " + count);
    }
    }
    }@



  • Ok. I get it done already.. Thank You so much for your help..


Log in to reply
 

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