Reputation: 6414
I'm using a QML list view which displays one element at a time
ListView
{
model: cppobj.list
...
}
cppobj
is a C++ object which can be modified, i.e. items can be removed, appended, etc. If an element is appended, the ListView goes back to the first element. What's more ListView.onRemove
is not called. Any ideas how to cope with it?
Thanks
/edit: the append
function of the C++ object looks like that:
void append (QString str) { m_list.append(str); emit listChanged(m_list); }
Upvotes: 3
Views: 7152
Reputation: 241
In case you want to have a ListModel for variant JSON data that you can use directly in QML, you can have a look at the JsonListModel. It can synchronize JSON data to a ListModel so you do not lose the current scroll position of the list. You can also apply transition animations and have the full ListView/ListModel features available.
ListView
{
model: JsonListModel {
source: myJsonData
keyField: "id"
}
...
}
You can find a detailed guide how to use the JsonListModel here:
Upvotes: 0