Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Array length
Qt 6.11 is out! See what's new in the release blog

Array length

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 5.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wilson_chan
    wrote on last edited by
    #1

    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..

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leafaku
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • W Offline
        W Offline
        wilson_chan
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • L Offline
          L Offline
          leafaku
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • W Offline
            W Offline
            wilson_chan
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved