[Qt-interest] Using mapFromSource()in a QSortFilterProxyModel with a valid index, returns an invalid index if the filterAcceptsColumn()is overwritten for the same proxy model.

Patricia Santana Cruz patriciasc at openismus.com
Fri Mar 18 16:12:33 CET 2011


Hello everybody,

I have reported a bug already about the following issue, but maybe
somebody else have any ideas.

What is the problem?:
Using mapFromSource()in a QSortFilterProxyModel with a valid index,
returns an invalid index if the filterAcceptsColumn() is overwritten for
the same proxy model.

Can you give an example?:
Im am using 3 models (whch just stands for the name of the app):
1st model (base model)  = WhchTreeModel
2nd model (proxy model) = WhchTreeProxyModel
3rd model (proxy model) = WhchTableProxyModel

The 2nd and 3rd model are proxy models based on the 1st model and
connected with a treeView and tableView respectively.
I am using a window with two areas, one with the treeView on the left
hand side and another one with the tableView on the right hand side. The
intention is that every time an item is clicked on the treeView, its
children are displayed on the tableView.

For doing this, I populated the WhchTreeModel with all the data as you
can see here:
https://github.com/Patriciasc/WHCH/blob/master/src/whchTreeModel.cpp#L32
For filtering the needed columns and rows, I overwrote the following
functions for the proxy models:
WhchTreeProxyModel::filterAcceptsRow() =>
https://github.com/Patriciasc/WHCH/blob/master/src/whchTreeProxyModel.cpp#L11
WhchTreeProxyModel::filterAcceptsColumn() =>
https://github.com/Patriciasc/WHCH/blob/master/src/whchTreeProxyModel.cpp#L22
WhchTableProxyModel::filterAcceptsColumn() =>
https://github.com/Patriciasc/WHCH/blob/master/src/whchTableProxyModel.cpp#L10

As you can see, WhchTableProxyModel::filterAcceptsColumn() is currently
commented. When using this functions, a non valid QModelIndex is
returned by mapFromSource() in
https://github.com/Patriciasc/WHCH/blob/master/src/whchTableProxyModel.cpp#L24 and the tableView does show nothing, meanwhile, when not overwriting the function (that is the reason why it is commented now), it works perfectly fine (omitting the fact that it does not do the filtering :)).

The source code of the whole app is under:
https://github.com/Patriciasc/WHCH

Thanks in advance,
Patricia.
-- 
patriciasc at openismus.com
http://psconboard.blogspot.com/
www.openismus.com




More information about the Qt-interest-old mailing list