[Qt-interest] QTreeView and QSortFilterProxyModel

Alessandro Vanzulli alessandro.vanzulli at gmail.com
Tue Mar 24 23:17:02 CET 2009


Hi,
thanks for your clarification.

In my opinion, the filterAcceptsRow shall take care to evaluate also the
childs of root nodes, otherwise you cannot find a method for avoiding the
display of group1 item inside the view beacuse your model will count it and
provides the data to the view.

Bye,

Alessandro



On Tue, Mar 24, 2009 at 11:11 PM, Daniel <firmware at gmx.de> wrote:

> 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/df735131/attachment.html 


More information about the Qt-interest-old mailing list