Qt之导出PDF、HTML和Word(一)

内容提要:
1,Qt导出文件的基本原理;
2,QPrinter、HTML和PDF;
3,HTML编辑器;
4,HTML和Word;
5,qwt的图片和pdf导出

一、Qt绘图和导出文件的基本原理
Qt的二维图形引擎是基于QPainter类的。QPainter既可以绘制几何形状(点、线、矩形、椭圆、弧形、弦行、饼状图、多边形和贝塞尔曲线),也可以绘制像素映射、图像和文字。(参考《C++ GUI Programming with Qt》)
查看Qt的帮助文档,关于“QPainter”的描述:
The QPainter class performs low-level painting on widgets and other paint devices.
QPainter provides highly optimized functions to do most of the drawing GUI programs require. It can draw everything from simple lines to complex shapes like pies and chords. It can also draw aligned text and pixmaps. Normally, it draws in a "natural" coordinate system, but it can also do view and world transformation. QPainter can operate on any object that inherits the QPaintDevice class.
The common use of QPainter is inside a widget's paint event: Construct and customize (e.g. set the pen or the brush) the painter. Then draw. Remember to destroy the QPainter object after drawing. 
 QPainter 可以在任何“绘图设备”(继承自QPaintDevice的类)上进行绘画,例如:QWidget、QPixmap、QImage、QSvgGenerator等。要想在绘图设备上绘图,只需创建一个QPainter对象,再将指针传到该设备中即可在该设备的paintEvent中进行绘画。
QPainter也可以与QPrinter一起使用来打印文件和创建PDF文档。查看Qt的帮助文档,关于“QPrinter”的描述如下:
The QPrinter class is a paint device that paints on a printer.
This device represents a series of pages of printed output, and is used in almost exactly the same way as other paint devices such as QWidget and QPixmap. A set of additional functions are provided to manage device-specific features, such as orientation and resolution, and to step through the pages in a document as it is generated.
QPrinter 本质上也是一个绘图设备,在QPrinter上绘图和在其他设备上绘图的方法非常类似,不同的是一些设备相关的管理函数。 (参考《C++ GUI Programming with Qt》和  Qt之生成PDF )QPrinter可以设置两种输出格式: QPrinter::NativeFormat和 QPrinter::PdfFormat,前一种是直接打印,后一种是导出为pdf文档。

二、 QPrinter导出PDF
  • 4
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值