开发者

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

开发者 https://www.devze.com 2023-01-11 22:33 出处:网络
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.

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

精彩评论

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

关注公众号