QSortFilterProxyModel: index from wrong model passed to mapToSource - why?
I'm getting this in my application output and can't figure out the problem. My code, which is in a subclass of QTableView, with model() returning a QSortFilterProxyModel:
const QSortFilterProxyModel *proxy = dynamic_cast<const QSortFilterProxyModel*>(model());
QModelIndex proxy_index2 = proxy->index(row, column, QModelIndex());
QModelIndex model_index = proxy->mapToSource(proxy_index2);
What am I doing wrong? I'm using Qt 4.7.
Edit:
I'm not sure what's going on, but this code is working fine now. I did check that the index is valid, then just proceeded for the time being. I'm not sure what I changed that fixed the problem, but the code above is working fine at this point.
It would be helpful to know what fixed the problem of course so I can understand how to use Qt开发者_运维知识库 better, but I'd probably have to give you guys the rest of my code at the point when I saw the problem - and I have no copy of the code in that state. So, I guess it will have to remain a mystery unless I run into it again! Thanks
精彩评论