The article directories
-
-
- About the report
- Common Qt report schemes
- This section describes the solution selection
- conclusion
-
About the report
Do embedded basically do not use reports, but desktop applications often use report function, in Qt below the available report tools are also quite many, need to choose according to specific needs, reports of some format is more rules, some are more special, so combined with specific needs to choose the right scheme.
Common Qt report schemes
I know the common Qt report implementation scheme is as follows:
- Read and write Word through ActiveX, in word document to achieve table drawing. You can also manipulate Excel files, but rely on Microsoft’s COM component.
- Qxlsx open source table operation code; This does not rely on Microsoft offIC and COM components; Download address: download.csdn.net/download/wu…
- Third party report library, also open source: CuterePort, KDReports, Limereport, etc. Due to the urgency of the project, we did not study how to use these third-party libraries in detail. You can take a look when you have time
- Implemented in HTML, this needs to be combined with QTextDocument, which is a rich text document class.
- QPainter directly draws tables and data on QPrinter, which is a little fierce, that is, make the wheel by yourself, but it also has advantages, that is, the controllability is strong.
This section describes the solution selection
- ActiveX relies on Windows and cannot be cross-platform. If your software does not need to be cross-platform, it can also be used. It is quite powerful.
- Third-party library; If you have enough time, you can learn about third-party open source report libraries, which are said to be good reports and powerful.
- Qxlsx; This is a more powerful open source table library, you can generate Excel table files, and files can also insert charts (histogram, curve, line chart, pie chart, etc.), I also only used its table function, the use of relatively simple, can directly reference its source engineering file (.prJ). It works in most cases.
- HTML; This scheme I also tried, the effect is not good, mainly I know nothing about HTML, use bad……
- QPainter draw; QPainter can draw various graphics on arbitrary QPaintDevice class, since you can draw arbitrary graphics, the nature can draw out statements, just the implementation process can be a little trouble, need to compute planning such as coordinates, but is very flexible, report if more complex or special, can it create a template.
conclusion
The first time to use QT to do report printing, just began to use QXLSX, but the implementation effect is not too good, because the number of data lines and columns in the report is not fixed, and to print on a piece of A4 paper, with QXLSX implementation is more troublesome. Later, I changed to HTML, which was not ideal. Finally, I used QPainter to draw directly, and the effect was good. In the next chapter, I will introduce the use of QXLSX, and then I will sort out QPainter to draw reports.
Welcome to follow wechat official account: