You shouldn't need to have two models as the underlying data is the same for both TreeViews. This is one of the massive benefits of the MV(C) implementation of the Qt Model/View framework. It should definitely be possible to feed selected model indexes from one view to another using a QSortFilterProxy on the second to filter out the indexes that aren't required or rather filter in the nidexes that are required.
I imagine you would start by getting the selected indexes of the treeViewA using a QItemSelectionModel:
QItemSelectionModel* selectionModel = tableViewA->selectionModel();
To copy to clipboard, switch view to plain text mode
Then handle treeViewA::selectionChanged(const QItemSelection & selected, const QItemSelection & deselected) which will be emitted whenever the selection in treeViewA changes (obviously!) and do one of these:
QModelIndexList indexList = selectionModel->selectedIndexes()
// OR
QModelIndexList indexList = selectionModel->selectedRows()
// OR
QModelIndexList indexList = selectionModel->selectedColums()
QModelIndexList indexList = selectionModel->selectedIndexes()
// OR
QModelIndexList indexList = selectionModel->selectedRows()
// OR
QModelIndexList indexList = selectionModel->selectedColums()
To copy to clipboard, switch view to plain text mode
Problem comes in knowing what to do with that list of selected indexes. I was hoping that you would be able to somehow get a QSortFilterProxyModel to filter based on a collection of indexes. I've just had a look at the documentation and it's not obvious how to do that. If I come up with anything, I'll post.
Bookmarks