I have one class called Load which is loading data from database. Another class is to show the data in a table. In the function I am returning QSqlQueryModel which is: At the moment is just basic because I was not able to compile it:
QSqlQueryModel PersistenceAdapter::loadServerList(){
login();
cout<<"Loading data"<<endl;
QSqlQueryModel model = new QSqlQueryModel();
logout();
return model;
}
definition in header file as:
QSqlQueryModel loadServerList();
In the other class I receive it as:
setServersList(PersistenceAdapter.loadServerList());
definition of this one is:
void MainWindow::setServersList(QSqlQueryModel serverdata) {
//this->servers = serverdata;
//this->amodel->addData(serverdata);
}
The error is:
PersistenceAdapter.cpp:66:48: error: conversion from ‘QSqlQueryModel*’ to non-scalar type ‘QSqlQueryModel’ requested /usr/include/qt4/QtCore/qabstractitemmodel.h: In copy constructor ‘QSqlQueryModel::QSqlQueryModel(const QSqlQueryModel&)’: /usr/include/qt4/QtCore/qabstractitemmodel.h:360:5: error: ‘QAbstractTableModel::QAbstractTableModel(const QAbstractTableModel&)’ is private /usr/include/qt4/QtSql/qsqlquerymodel.h:59:20: error: within this context PersistenceAdapter.cpp: In member function ‘QSqlQueryModel PersistenceAdapter::loadServerList()’: PersistenceAdapter.cpp:70:12: note: synthesised method ‘QSqlQueryModel::QSqlQueryModel(const QSqlQueryModel&)’ first required here
Appreciate if anyone can help me with that...
QSqlQueryModel* model = new QSqlQueryModel();. Then you should return a reference or a pointer to the model and not try to copy it on the return which seems to be prohibited.