翻譯|實(shí)施案例|編輯:楊鵬連|2020-12-25 11:30:51.050|閱讀 350 次
概述:以下簡(jiǎn)單示例演示了如何在任何Qt應(yīng)用程序中輕松集成和使用NCReport。這些代碼與Qt4.6-Qt5.8兼容。項(xiàng)目文件設(shè)置基于Qt .pro文件語法。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
NCReport是一個(gè)基于Qt跨平臺(tái)應(yīng)用程序和UI框架,使用C++編寫的強(qiáng)大、快速、多平臺(tái)、容易使用的報(bào)告引擎庫、報(bào)表生成器、報(bào)表設(shè)計(jì)器、 報(bào)表記錄器、報(bào)表工具、報(bào)表解決方案。如果你在尋找Qt報(bào)表引擎、Qt報(bào)表工具、Qt報(bào)表庫等等,那么NCReport就是你的最佳選擇。并且NCReport兼容Qt5和Qt4。
該系統(tǒng)由兩部分組成:報(bào)告呈現(xiàn)庫和報(bào)告設(shè)計(jì)器GUI應(yīng)用程序。報(bào)表引擎可以單獨(dú)使用和實(shí)現(xiàn)。報(bào)告模板文件格式為XML格式,可以從文件,字符串或sql數(shù)據(jù)庫中加載模板。該系統(tǒng)能夠生成各種類型的輸出,例如直接打印機(jī),內(nèi)部預(yù)覽窗口,postscript,PDF,SVG,圖像,文本,HTML。報(bào)表設(shè)計(jì)器使創(chuàng)建報(bào)表XML定義變得非常容易。
NCReport現(xiàn)已更新至2.23.4版本,修復(fù)了一些小的bug,感興趣的朋友歡迎下載體驗(yàn)哦~
工程檔案
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
將報(bào)告運(yùn)行到預(yù)覽窗口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; }將報(bào)告運(yùn)行到預(yù)覽窗口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; }將報(bào)告生成為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正版授權(quán)的朋友歡迎咨詢
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自: