What is the best way to return the result of a SQL query to QML? I have this function that executes a query:
bool Storage::setQuery(QString query)
{
QSqlQuery qsqlQuery;
bool success = qsqlQuery.exec(query);
qDebug() << "Error setQuery" << m_sqlDatabase.lastError();
// What can I do here for store and return my data
while (success.next()) {
// do something with data
}
return data;
}
Currently this function returns a boolean
, but I would like to know how to send the results of a SELECT *
for example. What is the best way?