Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the implementation of Qt report

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

How to understand the Qt report implementation scheme, in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

About report

Report functions are often used in desktop applications, and there are many report tools available under Qt, which need to be selected according to specific needs. Some reports are in a regular format, while others are special, so they should be combined with specific needs to choose the appropriate program.

Common schemes of Qt report

The common Qt report implementations I know are as follows:

Read and write word through ActiveX, and realize the drawing of tables in word documents. You can also manipulate excel files, but rely on Microsoft's COM components

Qxlsx open source table manipulation code; this does not rely on Microsoft's offic and COM components; download address: https://download.csdn.net/download/wuquan_1230/13750036.

Third-party report libraries are also open source: cutereport, KDReports, limereport, and so on. Due to the urgency of the project, there is no detailed study of how these third-party libraries are used. You can take a look at it when you have time.

Implemented through html, this needs to be combined with QTextDocument,QTextDocument is a rich text document class.

QPainter draws tables and data directly on QPrinter, which is a bit fierce, that is, it makes its own wheels, but it also has the advantage of being more controllable.

A brief introduction to the choice of scheme

ActiveX depends on windows, can not cross-platform, if your software does not need cross-platform, can also be used, the function is still quite powerful, you can use word to make the template in advance, and then the program can fill the template with data.

Third-party libraries; if you have enough time, you can learn those third-party open source report libraries, which are said to be good and powerful.

Qxlsx; this is a relatively powerful open source table library, you can generate excel table files, and the file can also be inserted charts (histogram, curve, line chart, pie chart, etc.), I only used its table function, relatively simple to use, you can directly reference its source of the project file (.prj). It applies in most cases.

I also tried html; this kind of plan, the effect is not good, mainly because I know nothing about html, do not use well.

QPainter drawing; QPainter can draw any QPaintDevice class on a variety of graphics, since you can draw any graphics, then you can naturally draw a report, but the implementation process may be a little troublesome, the need to calculate planning location coordinates and so on, but very flexible, if the report is more complex or special, you can draw a template through the program.

The first time to use qt to do report printing, just started to use qxlsx, but the effect is not very good, because the number of rows and columns in the report is not fixed, and to print on a piece of A4 paper, using qxlsx to achieve it is more troublesome. Later, it was changed to html, which was not ideal. At last, it was drawn directly with QPainter, and the effect was good.

The answer to the question on how to understand the Qt report implementation solution is shared here. I hope the above content can be of some help to everyone. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report