开发者

How to get a QModelIndex of a row, found by a SELECT-query (QSqlQuery) without modifying the original QSqlQueryModel

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 high开发者_运维问答lighting 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"


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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜