tags:

views:

40

answers:

1

Hello,

I already asked the question but I was misunderstood, so I try to precicise the problem.

I am using a QSqlQueryModel for showing data from a SQLite Database, for the view I use a QTableView. Now I want to implement a "Search/Find/Replace" dialog, so I search the database with an additionally created QSqlQuery and let's say I find the record.

So how do I come from this found record in my extra QSqlQuery to my model/view-architecture?

The problem is, I want to highlight the found record and therefore I have to load a QItemSelectionModel with a specific QModelIndex. But I do not know any way how to do this, maybe my plan is not possible and there are other working solutions for finding text in a database model and highlighting the found ones in the QTableView.

I already know the documentation of QSqlQuery, QSqlQueryModel and QModelIndex, so please don't refer only to these pages, this wouldn't be much help..

Thanks!

PS: There is also a related question, which has not been answered yet: "How can i find the QModelIndex for given composite primary key, with QSqlTableModel"

A: 

Ok, i found the answer myself, maybe somebody else has the same problem, so I post the solution:

There is a function QAbstractItemModel::match() :)

philistion