Reputation: 21
I have a ListModel in Qml which is filled dynamically.
I would like to know how can I retrieve information regarding a row from the model when I do myModel.get(i). This returns an object but I do not know how to extract information from it. In the docs I saw all example with myModel.get(i)."something". But I do not have any field to call, I would like something like :
function getValue(i,columnIndex)
{
var obj = myModel.get(i)
var requestedValue = obj[columnIndex]
}
Thanks
Upvotes: 0
Views: 533
Reputation: 244282
When you want to access the attributes you must do it through the name of that attribute. For example
ListModel {
id: myModel
ListElement {
title: "Moby-Dick"
author: "Herman Melville"
}
ListElement {
title: "The Adventures of Tom Sawyer"
author: "Mark Twain"
}
}
You can access it in two ways:
{your Model}.get({index}).title
{your Model}.get({index})['title']
Upvotes: 1