开发者

QSortFilterProxyModel: index from wrong model passed to mapToSource - why?

开发者 https://www.devze.com 2023-01-18 23:12 出处:网络
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:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消