How to easily integrate and use NCReport in any Qt application

NCReport is a cross-platform application and UI framework based on Qt. It is a powerful, fast, multi-platform, and easy-to-use report engine library, report generator, report designer, report recorder, report tool, and report solution written in C++. If you are looking for Qt report engine, Qt report tool, Qt report library, etc., then NCReport is your best choice. And NCReport is compatible with Qt5 and Qt4.

The system consists of two parts: report presentation library and report designer GUI application. The report engine can be used and implemented separately. The report template file format is XML format, and the template can be loaded from a file, string or sql database. The system can generate various types of output, such as direct printer, internal preview window, postscript, PDF, SVG, image, text, HTML. The report designer makes it very easy to create report XML definitions.

NCReport has been updated to version 2.23.4, and some minor bugs have been fixed. Interested friends are welcome to download and experience it~

[Huidu.com] Download the latest trial version of NCReport

Report solution NCReport updated to version 2.23.3 | attached download

Engineering file

QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport

TARGET = MySimpleDemo
TEMPLATE = app
SOURCES += main.cpp

win32:CONFIG(release, debug|release) : LIBS += -L$$PWD/../ncreport/lib/ -lNCReport2
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../ncreport/lib/ -lNCReportDebug2

INCLUDEPATH += $$PWD/../ncreport/includes
Run the report to the preview window 1

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

NCReport *report = new NCReport();

report->setReportSource( NCReportSource::File ); // set report source type
report->setReportFile("myreport.ncr"); //set the report filename fullpath or relative to dir
report->runReportToPreview(); // run to preview output

// error handling
if( report->hasError())
{
    QMessageBox msgBox;
    msgBox.setText(QObject::tr("Report error: ") + report->lastErrorMsg());
    msgBox.exec();
}
else
{
    // show preview
    NCReportPreviewWindow *pv = new NCReportPreviewWindow();    // create preview window
    pv->setOutput( (NCReportPreviewOutput*)report->output() );  // add output to the window
    pv->setReport(report);
    pv->setWindowModality(Qt::ApplicationModal );    // set modality
    pv->setAttribute( Qt::WA_DeleteOnClose );    // set attrib
    pv->exec();  // run like modal dialog
}
delete report;

}
Run the report to the preview window 2
int main(int argc, char *argv[])
{
QApplication a(argc, argv);

NCReport *report = new NCReport();
report->setReportFile("myreport.ncr"); //set the report filename fullpath or relative to dir
report->runReportToShowPreview(); // run and show to preview output

// error handling
if( report->hasError())
{
    QMessageBox msgBox;
    msgBox.setText(QObject::tr("Report error: ") + report->lastErrorMsg());
    msgBox.exec();
}
delete report;

}Generate
the report as PDF
int main(int argc, char *argv[])
{
QApplication a(argc, argv);

NCReport *report = new NCReport();
report->setReportFile("myreport.ncr"); //set the report filename fullpath or relative to dir
report->runReportToPDF("c:/temp/myreportoutput.pdf")

// error handling
if( report->hasError())
{
    QMessageBox msgBox;
    msgBox.setText(QObject::tr("Report error: ") + report->lastErrorMsg());
    msgBox.exec();
}
delete report;

}
**Friends who want to know or purchase genuine NCReport licenses are welcome to consult Huidu online customer service

Guess you like

Origin blog.51cto.com/14874181/2576871