Hi,
I'm presenting model data in a MyTableView (subclassed from QTableView), which has the following selection settings:
mView->setSelectionBehavior(QAbstractItemView::SelectRow s);
mView->setSelectionMode(QAbstractItemView::ExtendedSelec tion);
Due to some other restrictions, my custom model is subclassed from QAbstractItemModel and is "projected" on QTableView through MySortFilterProxyModel subclassed from QSortFilterProxyModel.
In custom model I've reimplemented: index, parent, rowCount, columnCount, data, setData, flags, setHeaderData, headerData. In custom proxy model I've reimplemented: index, parent, rowCount, columnCount, data, filterAcceptsRow, filterAcceptsColumn, lessThan, flags, mapFromSource, mapToSource.
The problem is that MyTableView doesn't show anything selected (I always see unselected rows) even though the debug printout from its indexAt(...) shows correctly what model index the mouse is clicking/moving over.
After playing around a bit with different configurations I could see selected rows in MyTableView but only when I removed MyProxyModel or removed and replaced MyItemModel with QStandardItemModel.
1. No selection is visible in MyTableView (although I'm getting data from correct model indices):
QAbstractItemModel...........QSortFilterProxyModel ...........QTableView
.............|.................................... .......|................................|
.............|.................................... .......|................................|
....MyItemModel -----------------> MyProxyModel --------> MyTableView (result: ExtendedSelection set but no selection visble at all)
2. Rows are visibly selected in MyTableView (although ExtendedSelection doesn't work - multple rows can be selected only by Ctrl key + Left Mouse Button):
QAbstractItemModel QTableView
.............|.....................|
.............|.....................|
MyItemModel -----> MyTableView (result: ExtendedSelection set but single row selection only available)
3. Selection works perfectly:
....................................QTableView
............................................|
............................................|
QStandardItemModel -> MyTableView (result: ExtendedSelection set and works perfectly)
What am I missing?
Thanks in advance for any suggestions.
W.
Bookmarks