Reputation: 198
Hello everyone.
The issue thagt i encounter here is that in both views items are editable. In a tree view you can edit item's names, and this change should appear in a list view as well. The same goes for opposite direction. Changing name of a Cat item should reflect on a treeView cat item. Since it is two different models, the change is made only when you hover over another view. What i currently did is for a changed item in one of views, i search for a item in a another view via QModelIndex::match() and then just update that part of a view via emit dataChanged(). I am not sure this a good way. So if maybe you can give me some ideas on how this can be done better. Thank you.
Upvotes: 1
Views: 206
Reputation: 98505
You should have only one model. The QAbstractItemView::setRootIndex
method is all you need: you can set the current item in the tree as the root for the table view. Alternatively, you could use a proxy viewmodel to adapt the data for display in a particular form.
Upvotes: 1