Mapping Index from View to Model
I have a subclass called TableModel that is derived from QAbstractTableModel and the TableModel is fed into a QSortFilterProxyModel... and this is fed into a QTableView. Let's say I use match() in the QSortFilterProxyModel to find some data in the view and in return I get a QModelIndex of the cell. Also, my TableModel contains a QMap of an int that is mapped to a Trace*.
My question is : how do I use this QModelIndex from the view/proxy to get back to the Trace entry in TableModel? I have the cell location in the proxy but I want to get other hidden information about the entry in the model.
Thanks!
Re: Mapping Index from View to Model
First of all you should never access that internal structure directly. You should expose all the data you need using QAbstractItemModel API (choosing to wrap your structure (but not a pointer to it) into QVariant as last choice). If you want to map indices between models, use QAbstractProxyModel::mapToSource().