[SOLVED]function returning QSQLQueryModel
-
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; -
Hi,
Your function signature is wrong, getPartners returns an instance of QSqlQueryModel and the implementation returns a pointer to a QSqlQueryModel.
-
Hi,
Your function signature is wrong, getPartners returns an instance of QSqlQueryModel and the implementation returns a pointer to a QSqlQueryModel.
-
You got error in that case because you were returning a copy of QSqlQueryModel and you can't copy QObject derived class.
QSqlQueryModel *Controller::getPartners()
is the right signature -
You got error in that case because you were returning a copy of QSqlQueryModel and you can't copy QObject derived class.
QSqlQueryModel *Controller::getPartners()
is the right signature