0

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!

1 Answer 1

0

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

1
  • Hello, thanks for your answer but it's not very useful. I am already using QSqlQueryModel for my QTableView and it is naturally set to my QTableView. It is also working fine, but now I need to search in the Database without changing the QSqlQueryModel, because it should only highlight (->QItemSelectionModel) the found items. So my plan was to search in another QSqlQueryModel? or a QSqlQuery. Again my question: How is it possible to get a QModelIndex of a (for example) QSqlResult, which I got from my QSqlQuery? It could be a "reverse"-function of indexInQuery(), any ideas?
    – philistion
    Aug 13, 2010 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.