[Qt-interest] Find text in SQL list

Christopher Rasch-Olsen Raa christopher at technophile.info
Mon Jan 12 23:53:25 CET 2009


Mandag 12 januar 2009 23:04:58 skrev Israel Brewster:
> I have a QSqlTableModel, column 0 of which is displayed using a
> QListView. I need to find out if a particular value (QString) exists
> in said column, but I'm not seeing any search functions, either for
> QListView or QSqlTableModel. How can I accomplish this? Thanks.
>

There is QAbstractItemModel::match(). Can be used as such:
QModelIndexList matches = yourModel->match(yourModel->index(0, yourModel-
>fieldIndex("id")), Qt::DisplayRole, QVariant("Whatever you search for"));

Good luck. :)

-- 
Christopher



More information about the Qt-interest-old mailing list