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

Sajjad dosto.walla at gmail.com
Thu Nov 18 03:12:46 CET 2010


Hello Scott,

I have declare a slot against the line edit text changed signal to match
against the entered text to  the data string in the model and then
highlight.


I was wondering how to search  the custom model against  the entered string

Regards
Sajjad


On Thu, Nov 18, 2010 at 1:27 AM, Scott Aron Bloom <Scott.Bloom at onshorecs.com
> wrote:

> I have already sub-classed the QAbstractItemModel and re-inplemented the
> data() function. The function definition is as follows:
>
>
>
> *********************************
>
>     if (!index.isValid())
>
>         return QVariant();
>
>     TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
>
>     if(role == Qt::DecorationRole)
>
>       {
>
>         return QIcon(":/H3D/images/Node.png");
>
>       }
>
>     /*
>
>       display role is used to access string that
>
>       can be displayed as text in the view
>
>      */
>
>     else if(role == Qt::DisplayRole)
>
>       {
>
>         return item->data(index.column());
>
>       }
>
>     else if(role == Qt::UserRole)
>
>       {
>
>         return QPixmap(":/H3D/images/Node.png");
>
>       }
>
>     else
>
>       return QVariant();
>
>
>
>
>
>
>
> ************************************'
>
>
>
> By "my original " - did you mean  the original model that you have
> subclassed from QAbstractItemModel and what different value you meant?
>
>
>
>
>
> Yes I would add that function, and return a value for Qt::BackgroundRole
> and ForegroundRole
>
>
>
> Scott
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101118/19011ebb/attachment.html 


More information about the Qt-interest-old mailing list