Hi,
I would like to have 2 separate tables, one showing all the items, and the other one the current selection of the original items.
My current solution is as follows; I create a proxy of the original model, to which I also pass its item selection model. I overwrite the QSortFilterProxyModel::filterAcceptRow() function, and return true only if the row is selected. In order to ensure that the second table is updated each time that the selection is changed, I connect the signal selectionChanged which calles a wrapper slot that just invokes QSortFilterProxyModel::filterChanged(). I attach the minimal code that implements what I described above and a screenshot showing the desired behavior.
Although it works, I don't like this solution for the following reasons:
1) filterAcceptRow uses the info from the selection model and not from the source model to decide whether a row should be filtered or not, which may not be the neatest solution
2) filterChanged() exists only from Qt4.2 and I need my application to be compatible with Qt4.1 too
3) if I understand well, filterChanged() recalculates accepted rows for all the indexes of the source models, and not only the ones which were removed from/added to a selection. Given that I can have tens of thousands of rows in the original model, this does not look like an optimal solution.
Does anyone have a better idea of implementing such functionality?
Bookmarks