I am displaying a QSqlTableModel in QSqlTableModel::OnManualSubmit
mode.
I want to run SQL style queries on my local copy, for example I have a getMax
function that changes as I add new rows. If my user locally changes the QSqlTableModel
during interaction I expect the getMax
to produce a different input, but instead the getMax
function remotely queries the data and the result will always be the same independent of any changes the user has made.
int TestMe::getMax(QString col,QString table)
{
QSqlQuery query;
sf(query.exec("SELECT MAX("+col+") FROM "+table));
sf(query.first());
auto rec = query.record();
return rec.field(0).value().toInt();
}
How do I run queries on my local copy of the model?