Unsolved Display a QFileSystemModel in two Views: Tree View and a TableView/ListView of selected items
-
Hi,
I have a TreeView of a QFileSystemModel where I can select files for later use. I store the model indices of these files, and would like to show the selected files in a TableView. How could this be achieved?
-
Hi,
You could use a custom QSortFilterProxyModel to filter out the elements not matching your selection.
-
Thanks. I thought about doing this. But I might not understand the
QFileSystemModel
right yet. If I dobool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override { if(source_parent.data(FileSystemModel::IsCheckedRole)==true) return true; else return false; }
And display the view as a
TreeView
nothing is shown, because the root node hasIsCheckedRole
false. The way I implementedIsCheckedRole
is that my model simply contains a list ofQModelIndex
which stores the items for whichIsCheckedRole
is true (like this I could avoid walking through the tree). So the problem maybe is, that I have a hierarchical model but would only want a list in my second view. -
Why not pass it the selected model indexes from the selection model of your view and filter out everything that's not in that list ?