PDA

View Full Version : function to return QSQLquerymodel



cpuinthebrain
19th July 2015, 16:11
I want to make function returning qsqlquerymodel like this:


QSqlQueryModel Controller::getPartners(){

QSqlQueryModel *model = new QSqlQueryModel(this);
model->setQuery("SELECT ID, Name, Bulstat FROM partners");
return model;
}

i got the following error:
no viable conversion from 'QSqlQueryModel *' to 'QSqlQueryModel' return model;

anda_skoa
19th July 2015, 19:08
i got the following error:
no viable conversion from 'QSqlQueryModel *' to 'QSqlQueryModel' return model;

Your method has a return type of QSqlQueryModel, your local "model" variable is a pointer to a QSqlQueryModel, a.k.a. QSqlQueryModel*

Change the return type of your function.

Cheers,
_

milos1
27th July 2015, 13:12
try

QSqlQueryModel * Controller::getPartners(){

QSqlQueryModel *model = new QSqlQueryModel(this);
model->setQuery("SELECT ID, Name, Bulstat FROM partners");
return model;
}