mirror of
https://github.com/qmlnet/qmlnet.git
synced 2026-05-16 14:15:57 -06:00
[GH-ISSUE #62] Support for ObservableCollection<> #37
Labels
No labels
bug
enhancement
help wanted
help wanted
pull-request
question
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/qmlnet#37
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @pauldotknopf on GitHub (Aug 19, 2018).
Original GitHub issue: https://github.com/qmlnet/qmlnet/issues/62
You can set the
Repeater.modelproperty with an array, but it doesn't auto-update when the collection changes. You have to reset the property with the same value.Repeater.modelwill internally check if the type being set is aQQmlInstanceModel, and if it is, it will auto-update itself when signals are raised on the model.We should create derived type implementing
QQmlInstanceModelthat carries a .NETObservableCollection<>instance. And events raised on the .NET collection will raise the signals on theQQmlInstanceModel. This will allow us to bind lists toRepeaterandListViewQML components and have them automatically update/render when items are added/removed/updated.@visoplan-clemens commented on GitHub (Jan 20, 2021):
Hi,
we forked qmlnet for our application and it works not bad, so thanks for the great work!
Because we have a lot of lists in our application and updating the hole list each times leads to some noticeable performance problems we need to implement the support for the ObservableCollection and I would be happy to share the result when we're done and if it fits into your concept.
My idea was to implement it more or less the same way the support for arrays and list are implemented using the NetListModel. So basically creating a facade that implements the QAbstractListModel and that subscribes (using the NetTypeInfo, currently don't know exactly how but doesn't seem to be that complicated) to the events of the ObservableCollection and using the QAbstractListModel methods/signals to propagate these further to QML.
You are writing something about QQmlInstanceModel. Can you maybe explain a bit more what you mean, because I don't get the idea.
I also took a look into the PR regarding Model(AbstractItemModel) https://github.com/qmlnet/qmlnet/pull/215 but they doesn't look that usefull for me regarding this task. They seem to target more the usecase to implement an own class in C# that wants to use the AbstractItemModel features.
It would be great if you could give me some hints if there are some major things I overlooked or another approach would be better.
best regards