Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

could you tell me How can I populate ListItem.ValueSelector with values from a ListModel?

I can populate a list with fixed values ("X 1", "X 2", "X 3"), like this:

ListModel {
    id: contactmodel
    ListElement{
        name: "A"
        attributes: [
            ListElement { description: "A 1" },
            ListElement { description: "A 2" },
            ListElement { description: "A 3" }
        ]
    }
    ListElement {
        name: "B"
        attributes: [
            ListElement { description: "B 1" },
            ListElement { description: "B 2" },
            ListElement { description: "B 3" }
        ]
    }
    ListElement {
        name: "C"
        attributes: [
            ListElement { description: "C 1" },
            ListElement { description: "C 2" },
            ListElement { description: "C 3" }
        ]
    }
}

ListView {
    width: 180; height: 200

    model: contactmodel
    delegate:   ListItem.ValueSelector  {
        text: name
        values: ["X 1", "X 2", "X 3"]
        onClicked: label.text = i18n.tr(model.name)
    }

and I get this:

enter image description here

but if I use different values from the model (A 1, A 2, A 3 for A and B 1, B 2, B 3 for B...), by changing:

values: ["X 1", "X 2", "X 3"]

to:

values: attributes

I get this:

enter image description here

which seems different from the previous (see the missing value in the image).

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.