You cannot create a QSqlQueryModel on the stack and return it as the return value of a function. The class has neither a copy constructor nor an assignment operator, one of which would be required to accomplish this. Furthermore, your QSqlQuery is a memory leak. You might have more luck using something like this:
{
qry,prepare("select * from tbl_connections");
qry.exec();
model->setQuery(qry);
return model;
}
QSqlQueryModel * DBManager::loadConnectionData()
{
QSqlQuery qry(dbSQLite);
QSqlQueryModel * model = new QSqlQueryModel( this );
qry,prepare("select * from tbl_connections");
qry.exec();
model->setQuery(qry);
return model;
}
To copy to clipboard, switch view to plain text mode
You probably also need a ";" at the end of your select statement for proper syntax. Remember to call delete on the "model" instance after you are done with it to avoid a memory leak on that.
Bookmarks