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