-1

I have a treeview in which I have applied sorting/filtering using QSortFilterProxyModel.

When I perform some action on tree item(ex. RMB action), I refresh my data model(QAbstractItemModel).

I am using beginresetmodel() before refreshing my data model. After data model's refreshed, selection on selected item disappears. I have saved the selections before refreshing data model, and applied them back after the model is refreshed, but the items do not get selected.

I tried removing beginResetModel() before refreshing data model, and selection works fine in that case.

QSortFilterProxyModel documentation says:

However, beginResetModel() / endResetModel() returns the proxy model to its original state, losing selection information, and will cause the proxy model to be repopulated."

How can I retain selection while keeping beginResetModel() / endResetModel() when refreshing data model?

1

1 Answer 1

-1

I am able to fix this by refreshing the seleced rows instead of reloading complete data model.

Sign up to request clarification or add additional context in comments.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.