Is it possible to put a query like
Code:
SELECT SUM(column) FROM mytable
inside a QSqlTableModel?
I woud get the sum of table without re-querying the database, because I already have the model...
Printable View
Is it possible to put a query like
Code:
SELECT SUM(column) FROM mytable
inside a QSqlTableModel?
I woud get the sum of table without re-querying the database, because I already have the model...
Do you want it as a separate row or a separate column or how? I think the best way would be to use a proxy model.
This example may help
Code:
QSqlQuery query; query.exec("SELECT MAX(id) FROM mytable"); if (query.next()) { myStringResult = query.value(0).toString(); } query.finish();
off course you need to replace the SQL code inside the .exec(_)
Ok, but I would use some Qt model.
If I used a model to connect to the database, I would not to make an sql query.
There is a way to put compicated query inside the model?
G
You can use QSqlQueryModel.