O Manual de Programação do KDevelop: Printing Support

Página seguinte Página anterior Índice geral

### 7. Printing Support

Printing is usually provided by your application to let the user create a printed version of the document he created with the application; therefore only needed for those programs that are used to produce something the user may want to print out, e.g. text or pictures. In any case, this requires an interface that is provided by the Qt library by two classes: the `QPrintDialog` class, offering the printing dialog, and the `QPainter` class that is also used to draw the widget's contents usually. As the view-class of an application is responsible for displaying a document, it also is responsible for printing.

### 7.1 The Qt Print Dialog

The Qt Printer dialog can be used including `qprintdialog.h`. When using the KDE framework application, this is already used by the view class, so you only have to complete the implementation of the method `print()` by using `QPainter`.

### 7.2 The QPainter Class

Independent of the printer's capabilities, you can use `QPainter` to draw your document onto the printer provided by `QPrinter` like you would when drawing onto a widget. The only difficulty would be where you have to implement the way things have to be printed.

Página seguinte Página anterior Índice geral