Re: [Interest] QSortFilterProxyModel::removeRows()
El dv 01 de 06 de 2012 a les 14:15 +0900, en/na Paul England va escriure: Hi I wrote this really long email, and learned a lot about the problem in doing so. So, I guess it was time well spent. Still frustrated. Here's the summed up problem: I have a QAbstrctTabelModel, QSortFilterProxyModel, QItemDelegate, and a QTableView (all subclassed). As you'd expect, the QSortFilterProxyModel filters out what I don't want, the delegate paints what I do, and the view displays everything. Some rows are updated, and based on user-defined criteria, need to be removed *AFTER* the proxy has let them in. Before, I was calling invalidate() in the proxy, but that was calling filterAcceptsRow() on all rows (visible or not). Yikes. So, I'm now doing removeRows() for the row(s) that must be removed. Caveat: my subclassed delegate's paint() is being passed a QModelIndex() with the *old* data. Example, my rows are. Harry Larry Bob bool my_proxy::removeRows( int row, int count, const QModelIndex ) { beginRemoveRows( QModelIndex(), row, count + row - 1 ); // remove data from model here endRemoveRows(); } if I do: removeRows( 2, 1 ); My model will then show it only has two items. Harry and Bob HOWEVER, for the subsequent call to my_delegeate::paint( QPainter*, const QStyledOptionViewItem opt, const QModelIndex index ) will have the old index. paint will be called twice, and index.data().toString() will have Harry for the 1st one, and Larry for the 2nd. Am I missing something? Thanks Perhaps the fact that indexes are 0-based ? 0 - Harry 1 - Larry 2 - Bob So if you call removeRows( 2, 1 ); you're removing Bob, as expected... ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] QSortFilterProxyModel::removeRows()
On 06/01/2012 03:01 PM, Jordi Pujol wrote: El dv 01 de 06 de 2012 a les 14:15 +0900, en/na Paul England va escriure: Hi I wrote this really long email, and learned a lot about the problem in doing so. So, I guess it was time well spent. Still frustrated. Here's the summed up problem: I have a QAbstrctTabelModel, QSortFilterProxyModel, QItemDelegate, and a QTableView (all subclassed). As you'd expect, the QSortFilterProxyModel filters out what I don't want, the delegate paints what I do, and the view displays everything. Some rows are updated, and based on user-defined criteria, need to be removed *AFTER* the proxy has let them in. Before, I was calling invalidate() in the proxy, but that was calling filterAcceptsRow() on all rows (visible or not). Yikes. So, I'm now doing removeRows() for the row(s) that must be removed. Caveat: my subclassed delegate's paint() is being passed a QModelIndex() with the *old* data. Example, my rows are. Harry Larry Bob bool my_proxy::removeRows( int row, int count, const QModelIndex ) { beginRemoveRows( QModelIndex(), row, count + row - 1 ); // remove data from model here endRemoveRows(); } men if I do: removeRows( 2, 1 ); My model will then show it only has two items. Harry and Bob HOWEVER, for the subsequent call to my_delegeate::paint( QPainter*, const QStyledOptionViewItem opt, const QModelIndex index ) will have the old index. paint will be called twice, and index.data().toString() will have Harry for the 1st one, and Larry for the 2nd. Am I missing something? Thanks Perhaps the fact that indexes are 0-based ? 0 - Harry 1 - Larry 2 - Bob So if you call removeRows( 2, 1 ); you're removing Bob, as expected... Sorry for not being clear. I am taking the 0-based index into account. removeRows should actually pass 1,1 in that case. I know that it's not working b/c when paint is called, I grab the underlying data structure that supposedly changed (indexed by row). I'm checking it against QModelIndex::data() within paint() and they do not match. ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
[Interest] QSortFilterProxyModel::removeRows()
Hi I wrote this really long email, and learned a lot about the problem in doing so. So, I guess it was time well spent. Still frustrated. Here's the summed up problem: I have a QAbstrctTabelModel, QSortFilterProxyModel, QItemDelegate, and a QTableView (all subclassed). As you'd expect, the QSortFilterProxyModel filters out what I don't want, the delegate paints what I do, and the view displays everything. Some rows are updated, and based on user-defined criteria, need to be removed *AFTER* the proxy has let them in. Before, I was calling invalidate() in the proxy, but that was calling filterAcceptsRow() on all rows (visible or not). Yikes. So, I'm now doing removeRows() for the row(s) that must be removed. Caveat: my subclassed delegate's paint() is being passed a QModelIndex() with the *old* data. Example, my rows are. Harry Larry Bob bool my_proxy::removeRows( int row, int count, const QModelIndex ) { beginRemoveRows( QModelIndex(), row, count + row - 1 ); // remove data from model here endRemoveRows(); } if I do: removeRows( 2, 1 ); My model will then show it only has two items. Harry and Bob HOWEVER, for the subsequent call to my_delegeate::paint( QPainter*, const QStyledOptionViewItem opt, const QModelIndex index ) will have the old index. paint will be called twice, and index.data().toString() will have Harry for the 1st one, and Larry for the 2nd. Am I missing something? Thanks ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest