QtRpt report from Databse
-
Hello ,
I am using QtRpt for creating reports. I can generate report from tablewidget. When I trying to get data from database then I facing problem . Anyone can help in this?Below is My Code.
void MainWindow::on_btnGenrateReport_clicked() { QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName("/home/gtek/Work/validscan_proj/validscan_db"); if(!db.open()) { qDebug()<<"Database not Open"<<endl; } else { QSqlQuery qry; qry.prepare("select * from vs_channel"); if(!qry.exec()) { qDebug()<<"Error in Query"<<endl; } else { QtRPT *report = new QtRPT(this); while(qry.next()) { qDebug()<<qry.value(12).toString()<<endl; qDebug()<<qry.value(1).toString()<<endl; qDebug()<<qry.value(6).toString()<<endl; report->loadReport(":/chreport.xml"); connect(report,&QtRPT::setValue,[&](const int recNo, const QString paramName, QVariant ¶mValue, const int reportPage) { (void) reportPage; if(paramName=="channel_id") { paramValue=(recNo,qry.value(12).toString()); qDebug()<<paramValue<<endl; } if(paramName=="channel_tag") { paramValue=(recNo,qry.value(1).toString()); qDebug()<<paramValue<<endl; } if(paramName=="unit") { paramValue=(recNo,qry.value(6).toString()); qDebug()<<paramValue<<endl; } }); }report->printExec(); } } }
-
Hi,
QtRPT is not an official Qt module, so you should try contacting its author or use their forum.
In any case, you should also explain exactly what you are expecting and what you are getting.
-
Hello,
This problem is solved.here is the right code.
void MainWindow::on_btnGenrateReport_clicked() { QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName("/home/gtek/Work/validscan_proj/validscan_db"); if(!db.open()) { qDebug()<<"Database not Open"<<endl; } else { QSqlQuery qry; qry.prepare("select * from vs_channel"); if(!qry.exec()) { qDebug()<<"Error in Query"<<endl; } else { QtRPT *report = new QtRPT(this); while(qry.next()) { p = new pojo(); p->setChannel_id(qry.value(12).toString()); p->setChannel_tag(qry.value(1).toString()); p->setUnit(qry.value(6).toString()); plist.push_back(p); } report->loadReport(":/chreport.xml"); report->recordCount.append(plist.count()); connect(report,&QtRPT::setValue,[&](const int recNo, const QString paramName, QVariant ¶mValue, const int reportPage) { (void) reportPage; if(paramName=="channel_id") { paramValue=plist[recNo]->getChannel_id(); } if(paramName=="channel_tag") { paramValue=plist[recNo]->getChannel_tag(); } if(paramName=="unit") { paramValue=plist[recNo]->getUnit(); } }); report->printExec(); } } }
I had created one pojo class for getter setter method.
-
@Neel-0 where can i get the full source code
-
Hi,
Using the answer to a simple query.
-
@Mahesh-Arrajella The official web site of QtRPT project here http://www.qtrpt.tk
-
-
@Neel-0 Hey Bro Can You Share This Code ?
I am working on Report from the last three Days
help Me Brother
-
@ali-aydin there are none officially provided by the Qt Company. QtRpt is one well known. AFAIK, they have moved their website.
-
That's not enough information. Please open your own thread about that issue and provide complete information like Qt version used, platform, QtRpt version and full error output.
-
@aha_1980 Unfortunately the link http://www.qtrpt.tk is no more working.
To get official source of the project please use
https://sourceforge.net/p/qtrpt/discussion/general/