以下简单示例演示了如何在任何Qt应用程序中轻松集成和使用NCReport。这些代码与Qt4.6-Qt5.8兼容。项目文件设置基于Qt .pro文件语法。
NCReport是一个基于Qt跨平台应用程序和UI框架,使用C++编写的强大、快速、多平台、容易使用的 告引擎库、 表生成器、 表设计器、 表记录器、 表工具、 表解决方案。如果你在寻找Qt 表引擎、Qt 表工具、Qt 表库等等,那么NCReport就是你的最佳选择。并且NCReport兼容Qt5和Qt4。
该系统由两部分组成: 告呈现库和 告设计器GUI应用程序。 表引擎可以单独使用和实现。 告模板文件格式为XML格式,可以从文件,字符串或sql数据库中加载模板。该系统能够生成各种类型的输出,例如直接打印机,内部预览窗口,postscript,PDF,SVG,图像,文本,HTML。 表设计器使创建 表XML定义变得非常容易。
NCReport现已更新至2.23.4版本,修复了一些小的bug,感兴趣的朋友欢迎下载体验哦~
NCReport最新试用版
工程档案
QT += core guigreaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupportTARGET = MySimpleDemoTEMPLATE = appSOURCES += main.cppwin32:CONFIG(release, debug|release) : LIBS += -L$$PWD/../ncreport/lib/ -lNCReport2else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../ncreport/lib/ -lNCReportDebug2INCLUDEPATH += $$PWD/../ncreport/includes
将 告运行到预览窗口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;}
将 告运行到预览窗口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;}
将 告生成为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;}
**想要了解或购买NCReport正版授权的朋友欢迎咨询在线客服
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!