Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Qt example) using count as model has implications when you need scrolling #179

Open
tusooa opened this issue May 24, 2023 · 1 comment
Open

Comments

@tusooa
Copy link
Contributor

tusooa commented May 24, 2023

(See https://lily-is.land/kazv/kazv/-/merge_requests/26 )

When using count as the model in ListView, the problem is that model value will be changed whenever we add or remove an item, and the scroll will be reset. Using a QAbstractListModel is a better solution, because the model is a QObject, and its value (reference/pointer) won't change when we change it, thus eliminating the need to do special handling when the count changes.

@arximboldi
Copy link
Owner

Yes, that's true. I use QAbstractListModel in my real world code. It is a bit trickier to do and that's why I use the other mechanism for simplicity. But it would be worth adding an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants