QPrintEngine Class

The QPrintEngine class defines an interface for how QPrinter interacts with a given printing subsystem. More...

Header: #include <QPrintEngine>
qmake: QT += printsupport

Note: All functions in this class are reentrant.

Public Types

enum PrintEnginePropertyKey { PPK_CollateCopies, PPK_ColorMode, PPK_Creator, PPK_Duplex, PPK_DocumentName, …, PPK_CustomBase }

Public Functions

virtual ~QPrintEngine()
virtual bool abort() = 0
virtual int metric(QPaintDevice::PaintDeviceMetric id) const = 0
virtual bool newPage() = 0
virtual QPrinter::PrinterState printerState() const = 0
virtual QVariant property(QPrintEngine::PrintEnginePropertyKey key) const = 0
virtual void setProperty(QPrintEngine::PrintEnginePropertyKey key, const QVariant &value) = 0

Detailed Description

The common case when creating your own print engine is to derive from both QPaintEngine and QPrintEngine. Various properties of a print engine are given with property() and set with setProperty().

See also QPaintEngine.

Member Type Documentation

enum QPrintEngine::PrintEnginePropertyKey

This enum is used to communicate properties between the print engine and QPrinter. A property may or may not be supported by a given print engine.

ConstantValueDescription
QPrintEngine::PPK_CollateCopies0A boolean value indicating whether the printout should be collated or not.
QPrintEngine::PPK_ColorMode1Refers to QPrinter::ColorMode, either color or monochrome.
QPrintEngine::PPK_Creator2A string describing the document's creator.
QPrintEngine::PPK_Duplex20A boolean value indicating whether both sides of the printer paper should be used for the printout.
QPrintEngine::PPK_DocumentName3A string describing the document name in the spooler.
QPrintEngine::PPK_FontEmbedding19A boolean value indicating whether data for the document's fonts should be embedded in the data sent to the printer.
QPrintEngine::PPK_FullPage4A boolean describing if the printer should be full page or not.
QPrintEngine::PPK_NumberOfCopies5Obsolete. An integer specifying the number of copies. Use PPK_CopyCount instead.
QPrintEngine::PPK_Orientation6Specifies a QPrinter::Orientation value.
QPrintEngine::PPK_OutputFileName7The output file name as a string. An empty file name indicates that the printer should not print to a file.
QPrintEngine::PPK_PageOrder8Specifies a QPrinter::PageOrder value.
QPrintEngine::PPK_PageRect9A QRect specifying the page rectangle
QPrintEngine::PPK_PageSize10Obsolete. Use PPK_PaperSize instead.
QPrintEngine::PPK_PaperRect11A QRect specifying the paper rectangle.
QPrintEngine::PPK_PaperSource12Specifies a QPrinter::PaperSource value.
QPrintEngine::PPK_PaperSources21Specifies more than one QPrinter::PaperSource value.
QPrintEngine::PPK_PaperName26A string specifying the name of the paper.
QPrintEngine::PPK_PaperSizePPK_PageSizeSpecifies a QPrinter::PaperSize value.
QPrintEngine::PPK_PrinterName13A string specifying the name of the printer.
QPrintEngine::PPK_PrinterProgram14A string specifying the name of the printer program used for printing,
QPrintEngine::PPK_Resolution15An integer describing the dots per inch for this printer.
QPrintEngine::PPK_SelectionOption16 
QPrintEngine::PPK_SupportedResolutions17A list of integer QVariants describing the set of supported resolutions that the printer has.
QPrintEngine::PPK_WindowsPageSize18An integer specifying a DM_PAPER entry on Windows.
QPrintEngine::PPK_CustomPaperSize22A QSizeF specifying a custom paper size in the QPrinter::Point unit.
QPrintEngine::PPK_PageMargins23A QList<QVariant> containing the left, top, right and bottom margin values in the QPrinter::Point unit.
QPrintEngine::PPK_CopyCount24An integer specifying the number of copies to print.
QPrintEngine::PPK_SupportsMultipleCopies25A boolean value indicating whether or not the printer supports printing multiple copies in one job.
QPrintEngine::PPK_QPageSize27Set the page size using a QPageSize object.
QPrintEngine::PPK_QPageMargins28Set the page margins using a QPair of QMarginsF and QPageLayout::Unit.
QPrintEngine::PPK_QPageLayout29Set the page layout using a QPageLayout object.
QPrintEngine::PPK_CustomBase0xff00Basis for extension.

Member Function Documentation

[virtual] QPrintEngine::~QPrintEngine()

Destroys the print engine.

[pure virtual] bool QPrintEngine::abort()

Instructs the print engine to abort the printing process. Returns true if successful; otherwise returns false.

[pure virtual] int QPrintEngine::metric(QPaintDevice::PaintDeviceMetric id) const

Returns the metric for the given id.

[pure virtual] bool QPrintEngine::newPage()

Instructs the print engine to start a new page. Returns true if the printer was able to create the new page; otherwise returns false.

[pure virtual] QPrinter::PrinterState QPrintEngine::printerState() const

Returns the current state of the printer being used by the print engine.

[pure virtual] QVariant QPrintEngine::property(QPrintEngine::PrintEnginePropertyKey key) const

Returns the print engine's property specified by key.

See also setProperty().

[pure virtual] void QPrintEngine::setProperty(QPrintEngine::PrintEnginePropertyKey key, const QVariant &value)

Sets the print engine's property specified by key to the given value.

See also property().