[SOLVED]function returning QSQLQueryModel
I want to make function returning qsqlquerymodel like this:
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;
Your function signature is wrong, getPartners returns an instance of QSqlQueryModel and the implementation returns a pointer to a QSqlQueryModel.
Could you show how it should looks like?
I tried also create the object in the stack, i got error too.
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
Ahhh, i see, this is something new to me!Thank you.
You have more information about why you can't copy QObject derived class here