Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

How to filter QListView

From Wiki
Jump to: navigation, search
Article Metadata
Code ExampleCompatibility
Created: rahul.kulshreshtha (07 Oct 2010)
Last edited: hamishwillee (23 Jul 2012)


1. Create a model that will hold all data and fill it

   QStandardItemModel model;
   for (char i = 'A'; i <= 'Z'; ++i) {
       model.appendRow(new QStandardItem(QString("Item %1").arg(i)));

2. Create a proxy model which will be used to filter list.

   QSortFilterProxyModel proxyModel;

3. Link model and proxy model


4. Create a QListView

   QListView list;

5. Link proxy model and list view and show UI


6. Apply filter

   QRegExp regExp("*R*", Qt::CaseInsensitive, QRegExp::Wildcard);

This will automatically update QListView. See the example for more details and SIGNAL handling.

Special thanks to divanov and mkfnx for their contribution in thread

This page was last modified on 23 July 2012, at 12:41.
155 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.