[Solved]QSortFilterProxyModel dont find in the "folder"
-
Hellow!
I use this code:
@ searchModel.setSourceModel(itemModel);
connect(searchLineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(findInModel(const QString&)));@
@void RizekFaster::findInModel(const QString& str)
{
if(str.isEmpty())
{
dataTreeView->setModel(itemModel);
return;
}
searchModel.setFilterWildcard(str);
dataTreeView->setModel(&searchModel);
}@
But my sort model dont find items in "folders", it find only items which have not parents
For example:
This is my program with all item in my item model
!http://s1.hostingkartinok.com/uploads/images/2012/02/28e3848a1f4e041e2af0461851dde433.jpg(1)!
And it is my program with QSortFilterProxyModel
!http://s1.hostingkartinok.com/uploads/images/2012/02/58a21d47c6552e76ea79e8b186f40874.jpg(2)!
How can i do that my sort model find all items?
And other question:
How can i do that my QSortFilterProxyModel find items in all columns simultaneously?
In advance many thank for your help! -
Hi,
Did you try
@
QSortFilterProxyModel::setFilterKeyColumn(int)
@?
filterKeyColumn : int
This property holds the column where the key used to filter the contents of the source model is read from.
The default value is 0. If the value is -1, the keys will be read from all columns.By default it is only searching in the column 0
@
void RizekFaster::findInModel(const QString& str)
{
if(str.isEmpty())
{
dataTreeView->setModel(itemModel);
return;
}
searchModel.setFilterWildcard(str);
searchModel.setFilterKeyColumn(-1); /this solves/
dataTreeView->setModel(&searchModel);
}
@ -
I try to do it, but it is only mean that program will found items in difetent columns, but it is dont find in the "folders"(like Friends and My Friends in my screen)
-
I wrote a proxy you might use as inspiration. Depending on the size of your model, it might need serious performance enhancements, but it is a start. Check "this":http://developer.qt.nokia.com/forums/viewthread/7782 topic for details.
-
Thank you for all your help!
-
[quote author="Andre" date="1329732295"]I wrote a proxy you might use as inspiration. Depending on the size of your model, it might need serious performance enhancements, but it is a start. Check "this":http://developer.qt.nokia.com/forums/viewthread/7782 topic for details.
[/quote]
Great information.
Thanks.