[Qt-interest] Qt 4.5: What is the correct way of notifying a proxy model of removed rows of its source model?

Stephen Kelly steveire at gmail.com
Tue Sep 7 18:17:09 CEST 2010


Tilmann Krüger wrote:

> Hello everybody,
> 
> one would think that QAbstractProxyModel takes care of this all by itself.
> A closer look in the source code reveals that this is not the case.
> 
> My guess is to implement slots for the rowsAboutToBeRemoved() and
> rowsRemoved() signals of the source model, which call beginRemoveRows()
> and endRemoveRows() with the correct rows for the proxy.

Correct.

> 
> This, however, raises the question of how one is supposed to get the
> corresponding set of row numbers of the proxy model, which - to make
> things even more complicated - is not necessarily contiguous as the region
> in the source model.

It sounds like you should possibly be using QSortFilterProxyModel. What does 
your proxy do? At any rate, you should be able to get all the information 
about row numbers in your sourceRowsAboutToBeRemoved slot. If you can get 
the information in any other method, you can get it there too.

All the best,

Steve.

> 
> I hope that my problem is clear by what I wrote.
> 
> Any help is appreciated, including pointers to documentation I may have
> missed!
> 
> Thank you in advance!
> 
> Regards,
> 
> Tilmann





More information about the Qt-interest-old mailing list