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

Laura Arhire larhire at gmail.com
Thu Feb 4 12:01:41 CET 2010


On Thu, Feb 4, 2010 at 10:38 AM, Stephen Kelly <steveire at gmail.com> wrote:
>
>
> 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?
>

Each window consists of a list view and a tree view (there can be several
windows, each with it's own tree/list views which have their own proxies but
everything points to the same target model). The list view does indeed have
setRootIndex connected to one of the tree view signals. The tree view does
not touch the root index at all. It seemed the correct way to do it. The
point is to have something that looks similar to the windows explorer.

> > 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.
>

You are right, I interpreted the documentation incorrectly. The row count
was wrong, it should have been 0 but it was whatever row count was
"expected" to be in the "folder". Setting the correct row count solved this.

Thanks for the help.

> 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
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100204/2552e6e3/attachment.html 


More information about the Qt-interest-old mailing list