[Qt-interest] QSortProxyModel - row being filtered before it is inserted

Stephen Kelly steveire at gmail.com
Thu Feb 4 09:38:51 CET 2010



Laura Arhire wrote:
> In order to show the model properly for each view, I'm using a filter
> proxy: this proxy filters the structure in such a way that:
> * list views (which just show one "directory" at a time) show all items
> * tree views show the whole structure, but only "directories"
>

Do you use setRootIndex for this? Can "items" and "directories" be mixed in
the same level?

> From the stack trace, the filterAcceptsRow seems to be called when I call
> beginInsertRows on the target model - and if I look at Qt source code,
> that is indeed what should happen.

Actually that shouldn't happen AFAIU. in QSFPM::create_mappings there should
be an early return if the parent is already mapped (in which case the
rowcount is already > 0) or an empty mapping is created (in which case
rowcount == 0 and the filter methods are not called).

Are you certain your model is reporting the correct rowcount when you call
beginInsertRows? Are there any code paths where you change internal model
data without emitting any signals? Those are the two things that come to my
mind.

All the best,

Steve.


> But I don't think this should happen -
> I also know how to fix this, since I don't know anything about the rows
> being populated until after they are populated.
>
> Can anyone spot what I'm missing?
>
> Thanks,
> Laura



More information about the Qt-interest-old mailing list