[Qt-interest] QSortFilterProxyModel - the parent item does not match i want to go down to the child as well and filter

Scott Aron Bloom Scott.Bloom at onshorecs.com
Thu Nov 18 00:57:59 CET 2010


Highlighted or filtered....

 

Let me give you an example of filtered...

 

Empty Root Node

|

--- Child 1

|         |

|        --------A

|       ---------C

----Child 2

|        |

|       ---------B 

|       ---------D

 

Now, if you filtered using "typical" string based filtering that the
QSFPM uses, by setting setFilterRegExp, and you set it to match "A"

 

Your tree would be blank, because neither Child 1 or Child 2 would
match.

 

What I have been talking about, is modifying the model, so when you set
the filter to A, you would have Child 1 and A, but no C child or Child 2

 

However, itf its expensive to get each child, the filterAcceptsRow
method can quickly get very very expensive very quickly.

 

As to a highlight... How I would do it, without a filter proxy model, I
would modify my original and when it matches, return a different value
for the appropriate roles in the Data method

 

Scott

 

 

 

From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Sajjad
Sent: Wednesday, November 17, 2010 1:46 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] QSortFilterProxyModel - the parent item does
not match i want to go down to the child as well and filter

 

Hello Scott,

 

I believe that i am causing some misunderstanding here. All  the
examples i have been following about QSortFilterProxyModel shows that
the Filtered model shows the reduced view based on the regular
expression pattern.

 

 

In my case i do not want to show only the item of the tree that matches
the pattern, the whole tree will be there as it is, but the item that
matches the pattern will be high-lighted in the view. Even if the parent
is not expanded the matched pattern will be shown high-lighted in the
expanded tree view.

 

 

Regards

Sajjad 

On Wed, Nov 17, 2010 at 4:00 PM, Scott Aron Bloom
<Scott.Bloom at onshorecs.com> wrote:

Make sure your filter check is minimal and fast...

 

But if you want to show a parent, if any of its children pass, then you
have to check the children...


Scott

 

From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Sajjad
Sent: Wednesday, November 17, 2010 1:00 AM


To: qt-interest at trolltech.com

Subject: Re: [Qt-interest] QSortFilterProxyModel - the parent item does
not match i want to go down to the child as well and filter

 

Any other suggestion to achieve this efficient manner to avoid this
run-time issue?

 

 

Regards 

Sajjad

On Mon, Nov 15, 2010 at 3:21 AM, Scott Aron Bloom
<Scott.Bloom at onshorecs.com> wrote:

Its actually quite easy to do.

 

However, it can be very very expensive from a runtime POV.. since the
complete child tree will have to be evaluated

 

Simply derive from QSFPM and overload filterAcceptsRow

 

Scott

 

From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Sajjad
Sent: Sunday, November 14, 2010 5:38 PM
To: qt-interest at trolltech.com
Subject: [Qt-interest] QSortFilterProxyModel - the parent item does not
match i want to go down to the child as well and filter

 

Hello forum,

 

I have loaded a database in the tree-hierarchy with the QTreeView and i
want to highlight a particular tree item by the regular expression
entered by  the user in

the line edit.  

 

I am using the QSortFilterProxyModel to get this done. According to  the
manual ,

 

For hierarchical models, the filter is applied recursively to all
children. If a parent item doesn't match the filter, none of its
children will be shown. 

 

I want to over-ride the feature in the bold text and i want to apply
filter both to the parent and child . But the parent item does not match
i want to go down to the 

 

child as well.

 

I think i have to subclass the QSortFilterProxyModel. Am in the right
track?

 

 

Regards

Sajjad


_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest

 


_______________________________________________
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/20101117/e575f23b/attachment.html 


More information about the Qt-interest-old mailing list