DNamto
DNamto

Reputation: 1362

Listmodel issue in QML

I need to get the count of items in the array of my list Model, where array is the one of the element of the list. Kindly refer following code snippet for the same.

I need to get the count of 'lValues' in the list element. (for example in terms of C++ : sizeof. lValues[])

ListModel {
        id: primaryList
        ListElement {
            Color: "label"
            lValues: [
                ListElement { lValues: 20 },
                ListElement { lValues: 0  },
                ListElement { lValues: 50 },
                ListElement { lValues: 60 },
                ListElement { lValues: 35 },
                ListElement { lValues: 70 },
                ListElement { lValues: 80 }
            ]
    }
}

Thanks in adavnce

Upvotes: 1

Views: 1479

Answers (1)

Dmitry Melnikov
Dmitry Melnikov

Reputation: 743

Is this what You want?

ListModel {
        id: primaryList
        ListElement {
            Color: "label"
            lValues: [
                ListElement { lValues: 20 },
                ListElement { lValues: 0  },
                ListElement { lValues: 50 },
                ListElement { lValues: 60 },
                ListElement { lValues: 35 },
                ListElement { lValues: 70 },
                ListElement { lValues: 80 }
            ]
    }
}
Text {
    text: primaryList.get(0).lValues.count
}

Upvotes: 2

Related Questions