1
Discussion | Обсуждение / Re: How to dynamically load data from a mysql database?
« on: December 08, 2016, 05:04:13 am »Hi
It's hard to say Your compiler knows it better
What I see at once and it's alarming me LimeReport::ReportEngine instance is created but not deleted - it is memory leak.
Another part of the code, as I understand it, you've got from the demo and it is correct
Can I ask you why you use callbackDatasource instead sending a model to LimeReport ?
Hi, Alex
Because I don't know how to sending a model to LimeReport,can you help me?
thank you.
Is it like the following code?The code compiler is no problem, but run error, I was using limereprot in the MFC.
LimeReport::ReportEngine *report = new LimeReport::ReportEngine(m_pWnd);
QSqlDatabase db = QSqlDatabase::addDatabase(m_strDbType);
db.setHostName(m_strHostName);
db.setDatabaseName(m_strDbName);
db.setUserName(m_strUserName);
db.setPassword(m_strPassword);
if (db.open())
{
m_customers = new QSqlQuery(m_strQuerySql, db);
QSqlQueryModel* customersModel = new QSqlQueryModel();
customersModel->setQuery(m_strQuerySql);
report->dataManager()->addModel("ds1", customersModel, true);
report->loadFromFile(m_strReprotName);
report->previewReport();
delete customersModel;
};
delete report;
The following code works fine
QWinWidget *pWidget = new QWinWidget(this);
LimeReport::ReportEngine *report = new LimeReport::ReportEngine(pWidget); //to create reportengine
report->loadFromFile("myfirstrpt.lrxml");// to load report template file
report->previewReport();// to generate report and preview