jeudi 4 février 2016

How to get the row of a record in QSqlTableModel?

i'm new using qt and i don't found a way to retrieve the row of some element that i know only the fields (email for example).

I have a model(QSqlTableModel) and i want to know which the row of the record in table "person" with email "a@gmail.com". The QSqlQuery not return a row, how can i achieve this?

QSqlQuery query;
query.exec(QString("SELECT * FROM person WHERE email = \"%1\";").arg("a@gmail.com"));
// the query.exec not return rows, but i need to know the row to edit some (not selectable) item, using QSqlTableModel::setRecord(int row, ...) for example.

Aucun commentaire:

Enregistrer un commentaire