class KPrinter


Table of contents
Modules
kdeprint Classes
All Classes
Module kdeprint
Namespace global
Class KPrinter
Inherits QPaintDevice, KPReloadObject

This class is the main interface to access the KDE print framework. It allows KDE applications to easily access the print system, through an interface that is compatible with QPrinter. So that the porting of an existing application should be as easy as replacing any occurrence of QPrinter by KPrinter. However applications that explicitly used the QPrintDialog class must be changed to the standard KPrinter way of accessing the print dialog.

Basically, a KDE application will use the KPrinter object as a paint device, and will draw on it using QPainter. In a standard application, the use of the KPrinter class will look like this:

#include 
#include 

void MyClass.doPrint() { KPrinter printer;

// do some printer initialization printer.setFullPage( true );

// initialize the printer using the print dialog if ( printer.setup( this ) ) { // create a painter to paint on the printer object QPainter painter;

// start painting painter.begin( &printer ); // stop painting, this will automatically send the print data to the printer painter.end(); } }

The KPrinter interface also allows some more advanced possibilities, like the customization of the print dialog to integrate application specific print options. This is done by subclassing KPrintDialogPage and adding the page using addDialogPage().

When compiling an application that uses KPrinter, you must link to -lkdeprint, which when using the standard KDE build framework can be done by adding $(LIB_KDEPRINT) to _LDADD.

The central interface class to access the KDE print system. Author Michael Goffioul

See also QPrinter, KPrintDialogPage



enums

enum details

methods