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

StatusQ/Utils: Reliable and generic way to bind to model's count #15374

Closed
micieslak opened this issue Jun 28, 2024 · 0 comments · Fixed by #15375
Closed

StatusQ/Utils: Reliable and generic way to bind to model's count #15374

micieslak opened this issue Jun 28, 2024 · 0 comments · Fixed by #15375
Assignees
Labels
bug Something isn't working ui-team

Comments

@micieslak
Copy link
Member

Description

Models like ListModel and SortFilterProxyModel have handy count property. However that property is not part of QAbstractItemModel so shouldn't be accessed on models provided from outside in given component. Most proxy models doesn't have count method, in nim code it's present in most models but it's repeating code causing code duplication and risk of bugs.

In our codebase we also use rowCount directly but in most cases it's not reliable because expression won't be re-evaluated on count change.

That problem can be easily solved by generic attached type providing count for every QAbstractItemModel. Than it's enough to use myModel.ModelCount.count to have reliable, bindable count for every QAIM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ui-team
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant