Hello,
When I run the code below, I get the error:
error: C2664: 'QSqlTableModel::QSqlTableModel(QObject *,QSqlDatabase)' : cannot convert parameter 1 from 'getData *const ' to 'QObject *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
What is wrong?
class getData
{
public:
QVector<QString> inputData();
QMap<QString,double> setParams();
private:
};
class getData
{
public:
getData(const QDate &date, const QSqlDatabase &dbase);
QVector<QString> inputData();
QMap<QString,double> setParams();
private:
QDate date_;
QSqlDatabase dbase_;
QSqlTableModel *model_;
};
To copy to clipboard, switch view to plain text mode
getData
::getData(const QDate &date,
const QSqlDatabase &dbScenarios
) : date_
(date
), dbase_
(dbase
){}
getData::getData(const QDate &date, const QSqlDatabase &dbScenarios) : date_(date), dbase_(dbase)
{}
To copy to clipboard, switch view to plain text mode
QVector<QString> getData::inputData(){
modelScenarios->setTable("Scenarios");
modelScenarios->setFilter(filter);
modelScenarios->select();
while(modelScenarios->canFetchMore()){
modelScenarios->fetchMore();
}
….
return ….
}
QVector<QString> getData::inputData(){
QString filter="";
model_ = new QSqlTableModel(this, dbase_);
modelScenarios->setTable("Scenarios");
modelScenarios->setFilter(filter);
modelScenarios->select();
while(modelScenarios->canFetchMore()){
modelScenarios->fetchMore();
}
….
return ….
}
To copy to clipboard, switch view to plain text mode
Bookmarks