[Qt-interest] QTreeView and QSortFilterProxyModel

Daniel firmware at gmx.de
Tue Mar 24 23:11:49 CET 2009


my filterAcceptsRow function does not filter the data of toplevel items
(here: group1)

Assume, the filter would be "item.2" I end up with
- group1
   - item12
- group2
   - item22

If I was applying the filter to toplevel items, I would have an empty tree.
All I want is to find out how many children pass the filter. If none, then
the group should not be displayed.

Thanks for your thoughts, though!
Daniel



2009/3/24 Alessandro Vanzulli <alessandro.vanzulli at gmail.com>

> Hi,
>
> one question? How your filterAcceptsRow accept the group1row ??
>
> It shall be discarded from the filter beacuse it does not match with your
> filter criteria. Is it correct?If yes, the source of problem is located in
> the filterAcceptsRow method.
>
> Bye
>
> Alessandro
>
>
>
>
> 2009/3/24 Daniel <firmware at gmx.de>
>
>> Hi all,
>>
>> I have a custom QTreeView and a custom QSortFilterProxyModel with a
>> reimplemented filterAcceptsRow function.
>> Assume, the model contains:
>>
>> - group1
>>    - item11
>>    - item12
>> - group2
>>    - item21
>>    - item22
>>
>> Now I apply a string filter "item2?" only for the items, so group 1 would
>> empty. This works without problems and results in:
>>
>>  group1
>> -group2
>>    - item21
>>    - item22
>>
>> I want the empty toplevel groups to be hidden, e.g.
>>
>> -group2
>>    - item21
>>    - item22
>>
>> I have tried to determine the number of children that pass the filter
>> within filterAcceptsRow with no success.
>> Another approach was to hide the empty toplevel row in the QTreeView
>> reimplementing drawRow, but this ended up still showing an empty line.
>>
>> Any ideas, friends?
>> Daniel
>>
>>
>> _______________________________________________
>> 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/20090324/cd4197e8/attachment.html 


More information about the Qt-interest-old mailing list