开发者

How to get a QModelIndex from another QSqlQuery used for searching the database (needed for selecting the found items)

I have a problem when dealing with my QSqlQueryModel. I want to search the 开发者_如何学编程database for some items and select them in my QTableView with QItemSelectionModel which needs a QModelIndex.

What I don't understand is how should I search in order to get the corresponding QModelIndex for my model/view architecture. I can't possibly use the model itself, because it would mess up the items shown in the view. So a QSqlQuery or an extra QSqlQueryModel would maybe be an option, but how is it possible to translate from their result-index (.at()?) to a QModelIndex which fits to my Model/View-System...

Thanks in advance!


The easiest way is to take a look at QSQLQueryModel, and set your TableView's model to it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜