PDA

View Full Version : Qt App and NCReport



Kclark
10th January 2011, 13:37
I tried using NCReport in my application as a component for reporting services. I am using Visual Studio 2008 and Qt 4.5.3 for development and I have also installed a specially build version of NCReport compatible to Qt 4.5.3. Since I have VS solution, so my projects are not .pro and are .vcproj.

Instead of editing my .vcproj I have added the necessary dlls (ncreport2.dll, ncreportd2.dll), included the include folder, added the necessary library and also copied some of the dlls available in the (NCREPORT INSTALL FOLDER)/bin directory to my projetc's debug directory.

Now my code is

report = new NCReport();
report->reset(true);
report->setReportFile(QString(QApplication::applicationDir Path() +
QDir::separator() + "reports" + QDir::separator()
+ "MitigationAnalysis.xml"));
output = 0;
output = new NCReportPreviewOutput();
output->setAutoDelete( false );
report->setOutput(output);
report->runReport();
if(!report->hasError())
{
pv = new NCReportPreviewWindow();
pv->setReport( report );
pv->setOutput((NCReportPreviewOutput *) output);
pv->setWindowModality(Qt::ApplicationModal);
pv->setAttribute(Qt::WA_DeleteOnClose);
pv->show();
}
else if( report->hasError())
{
bool error = report->hasError();
QMessageBox::about(this,"Error in Report", report->lastErrorMsg());
}



When I try to run this code the program throws and Access Violation Exception reading location........ and breaks at the line report->runReport(). No other information and I get confused about what to do.

Now, accidentally I tried to change the Filename of report and gave some wrong input string to it , and what I see is that the program doesn't break and shows me the last error message occurred in the report.

I am unable to understand this behavior. I am developing my application on WINDOWS XP (service pack 3). Please guide me if any one has faced the same problem or do me this favor.

Thanks

Lesiok
11th January 2011, 09:42
Be sure that You use correct NCReport DLL's (debug or release mode). We have this same problem after linking release DLL's to debug code.