tags:

views:

53

answers:

1

Hi there,

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!

A: 

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

http://doc.qt.nokia.com/4.5/qsqlquerymodel.html

Chris
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