Qt 4.8
|
The QPrinter class is a paint device that paints on a printer. More...
#include <qprinter.h>
Public Types | |
enum | ColorMode { GrayScale, Color } |
This enum type is used to indicate whether QPrinter should print in color or not. More... | |
enum | DuplexMode { DuplexNone = 0, DuplexAuto, DuplexLongSide, DuplexShortSide } |
This enum is used to indicate whether printing will occur on one or both sides of each sheet of paper (simplex or duplex printing). More... | |
enum | Orientation { Portrait, Landscape } |
This enum type (not to be confused with Orientation ) is used to specify each page's orientation. More... | |
enum | OutputFormat { NativeFormat, PdfFormat, PostScriptFormat } |
The OutputFormat enum is used to describe the format QPrinter should use for printing. More... | |
enum | PageOrder { FirstPageFirst, LastPageFirst } |
This enum type is used by QPrinter to tell the application program how to print. More... | |
enum | PageSize { A4, B5, Letter, Legal, Executive, A0, A1, A2, A3, A5, A6, A7, A8, A9, B0, B1, B10, B2, B3, B4, B6, B7, B8, B9, C5E, Comm10E, DLE, Folio, Ledger, Tabloid, Custom, NPageSize = Custom } |
Use QPrinter::PaperSize instead. More... | |
enum | PaperSize { A4, B5, Letter, Legal, Executive, A0, A1, A2, A3, A5, A6, A7, A8, A9, B0, B1, B10, B2, B3, B4, B6, B7, B8, B9, C5E, Comm10E, DLE, Folio, Ledger, Tabloid, Custom, NPageSize = Custom, NPaperSize = Custom } |
This enum type specifies what paper size QPrinter should use. More... | |
enum | PaperSource { OnlyOne, Lower, Middle, Manual, Envelope, EnvelopeManual, Auto, Tractor, SmallFormat, LargeFormat, LargeCapacity, Cassette, FormSource, MaxPageSource } |
This enum type specifies what paper source QPrinter is to use. More... | |
enum | PrinterMode { ScreenResolution, PrinterResolution, HighResolution } |
This enum describes the mode the printer should work in. More... | |
enum | PrinterState { Idle, Active, Aborted, Error } |
enum | PrintRange { AllPages, Selection, PageRange, CurrentPage } |
Used to specify the print range selection option. More... | |
enum | Unit { Millimeter, Point, Inch, Pica, Didot, Cicero, DevicePixel } |
This enum type is used to specify the measurement unit for page and paper sizes. More... | |
Public Types inherited from QPaintDevice | |
enum | PaintDeviceMetric { PdmWidth = 1, PdmHeight, PdmWidthMM, PdmHeightMM, PdmNumColors, PdmDepth, PdmDpiX, PdmDpiY, PdmPhysicalDpiX, PdmPhysicalDpiY } |
Public Functions | |
bool | abort () |
Aborts the current print run. More... | |
int | actualNumCopies () const |
Returns the number of copies that will be printed. More... | |
bool | collateCopies () const |
Returns true if collation is turned on when multiple copies is selected. More... | |
ColorMode | colorMode () const |
Returns the current color mode. More... | |
int | copyCount () const |
Returns the number of copies that will be printed. More... | |
QString | creator () const |
Returns the name of the application that created the document. More... | |
int | devType () const |
QString | docName () const |
Returns the document name. More... | |
bool | doubleSidedPrinting () const |
Returns true if double side printing is enabled. More... | |
DuplexMode | duplex () const |
Returns the current duplex mode. More... | |
bool | fontEmbeddingEnabled () const |
Returns true if font embedding is enabled. More... | |
int | fromPage () const |
Returns the number of the first page in a range of pages to be printed (the "from page" setting). More... | |
bool | fullPage () const |
Returns true if the origin of the printer's coordinate system is at the corner of the page and false if it is at the edge of the printable area. More... | |
HDC | getDC () const |
void | getPageMargins (qreal *left, qreal *top, qreal *right, qreal *bottom, Unit unit) const |
Returns the page margins for this printer in left, top, right, bottom. More... | |
bool | isValid () const |
Returns true if the printer currently selected is a valid printer in the system, or a pure PDF/PostScript printer; otherwise returns false. More... | |
bool | newPage () |
Tells the printer to eject the current page and to continue printing on a new page. More... | |
int | numCopies () const |
Returns the number of copies to be printed. More... | |
Orientation | orientation () const |
Returns the orientation setting. More... | |
QString | outputFileName () const |
Returns the name of the output file. More... | |
OutputFormat | outputFormat () const |
Returns the output format for this printer. More... | |
PageOrder | pageOrder () const |
Returns the current page order. More... | |
QRect | pageRect () const |
Returns the page's rectangle; this is usually smaller than the paperRect() since the page normally has margins between its borders and the paper. More... | |
QRectF | pageRect (Unit) const |
Returns the page's rectangle in unit; this is usually smaller than the paperRect() since the page normally has margins between its borders and the paper. More... | |
PageSize | pageSize () const |
Returns the printer page size. More... | |
QPaintEngine * | paintEngine () const |
Returns the paint engine used by the printer. More... | |
QRect | paperRect () const |
Returns the paper's rectangle; this is usually larger than the pageRect(). More... | |
QRectF | paperRect (Unit) const |
Returns the paper's rectangle in unit; this is usually larger than the pageRect(). More... | |
PaperSize | paperSize () const |
Returns the printer paper size. More... | |
QSizeF | paperSize (Unit unit) const |
Returns the paper size in unit. More... | |
PaperSource | paperSource () const |
Returns the printer's paper source. More... | |
QPrintEngine * | printEngine () const |
Returns the print engine used by the printer. More... | |
QString | printerName () const |
Returns the printer name. More... | |
QString | printerSelectionOption () const |
Returns the printer options selection string. More... | |
PrinterState | printerState () const |
Returns the current state of the printer. More... | |
QString | printProgram () const |
Returns the name of the program that sends the print output to the printer. More... | |
PrintRange | printRange () const |
Returns the page range of the QPrinter. More... | |
QPrinter (PrinterMode mode=ScreenResolution) | |
Creates a new printer object with the given mode. More... | |
QPrinter (const QPrinterInfo &printer, PrinterMode mode=ScreenResolution) | |
Creates a new printer object with the given printer and mode. More... | |
void | releaseDC (HDC hdc) const |
int | resolution () const |
Returns the current assumed resolution of the printer, as set by setResolution() or by the printer driver. More... | |
void | setCollateCopies (bool collate) |
Sets the default value for collation checkbox when the print dialog appears. More... | |
void | setColorMode (ColorMode) |
Sets the printer's color mode to newColorMode, which can be either Color or GrayScale . More... | |
void | setCopyCount (int) |
Sets the number of copies to be printed to count. More... | |
void | setCreator (const QString &) |
Sets the name of the application that created the document to creator. More... | |
void | setDocName (const QString &) |
Sets the document name to name. More... | |
void | setDoubleSidedPrinting (bool enable) |
Enables double sided printing if doubleSided is true; otherwise disables it. More... | |
void | setDuplex (DuplexMode duplex) |
Enables double sided printing based on the duplex mode. More... | |
void | setFontEmbeddingEnabled (bool enable) |
Enabled or disables font embedding depending on enable. More... | |
void | setFromTo (int fromPage, int toPage) |
Sets the range of pages to be printed to cover the pages with numbers specified by from and to, where from corresponds to the first page in the range and to corresponds to the last. More... | |
void | setFullPage (bool) |
If fp is true, enables support for painting over the entire page; otherwise restricts painting to the printable area reported by the device. More... | |
void | setNumCopies (int) |
Sets the number of copies to be printed to numCopies. More... | |
void | setOrientation (Orientation) |
Sets the print orientation to orientation. More... | |
void | setOutputFileName (const QString &) |
Sets the name of the output file to fileName. More... | |
void | setOutputFormat (OutputFormat format) |
Sets the output format for this printer to format. More... | |
void | setPageMargins (qreal left, qreal top, qreal right, qreal bottom, Unit unit) |
This function sets the left, top, right and bottom page margins for this printer. More... | |
void | setPageOrder (PageOrder) |
Sets the page order to pageOrder. More... | |
void | setPageSize (PageSize) |
Sets the printer page size based on newPageSize. More... | |
void | setPaperSize (PaperSize) |
Sets the printer paper size to newPaperSize if that size is supported. More... | |
void | setPaperSize (const QSizeF &paperSize, Unit unit) |
Sets the paper size based on paperSize in unit. More... | |
void | setPaperSource (PaperSource) |
Sets the paper source setting to source. More... | |
void | setPrinterName (const QString &) |
Sets the printer name to name. More... | |
void | setPrinterSelectionOption (const QString &) |
Sets the printer to use option to select the printer. More... | |
void | setPrintProgram (const QString &) |
Sets the name of the program that should do the print job to printProg. More... | |
void | setPrintRange (PrintRange range) |
Sets the print range option in to be range. More... | |
void | setResolution (int) |
Requests that the printer prints at dpi or as near to dpi as possible. More... | |
void | setWinPageSize (int winPageSize) |
Sets the page size to be used by the printer under Windows to pageSize. More... | |
QList< PaperSource > | supportedPaperSources () const |
Returns the supported paper sizes for this printer. More... | |
QList< int > | supportedResolutions () const |
Returns a list of the resolutions (a list of dots-per-inch integers) that the printer says it supports. More... | |
bool | supportsMultipleCopies () const |
Returns true if the printer supports printing multiple copies of the same document in one job; otherwise false is returned. More... | |
int | toPage () const |
Returns the number of the last page in a range of pages to be printed (the "to page" setting). More... | |
int | winPageSize () const |
Returns the page size used by the printer under Windows. More... | |
~QPrinter () | |
Destroys the printer object and frees any allocated resources. More... | |
Public Functions inherited from QPaintDevice | |
int | colorCount () const |
int | depth () const |
int | height () const |
int | heightMM () const |
int | logicalDpiX () const |
int | logicalDpiY () const |
QT_DEPRECATED int | numColors () const |
bool | paintingActive () const |
int | physicalDpiX () const |
int | physicalDpiY () const |
int | width () const |
int | widthMM () const |
virtual | ~QPaintDevice () |
Protected Functions | |
int | metric (PaintDeviceMetric) const |
Returns the metric for the given id. More... | |
void | setEngines (QPrintEngine *printEngine, QPaintEngine *paintEngine) |
This function is used by subclasses of QPrinter to specify custom print and paint engines (printEngine and paintEngine, respectively). More... | |
Protected Functions inherited from QPaintDevice | |
QPaintDevice () | |
Private Functions | |
void | init (PrinterMode mode) |
Properties | |
QScopedPointer< QPrinterPrivate > | d_ptr |
Friends | |
class | QAbstractPrintDialog |
class | QAbstractPrintDialogPrivate |
class | QPageSetupWidget |
class | QPrintDialogPrivate |
class | QPrintPreviewWidgetPrivate |
class | QTextDocument |
Additional Inherited Members | |
Static Public Functions inherited from QPaintDevice | |
static QWSDisplay * | qwsDisplay () |
Protected Variables inherited from QPaintDevice | |
ushort | painters |
Related Functions inherited from QPaintDevice | |
const Q_GUI_EXPORT QX11Info * | qt_x11Info (const QPaintDevice *pd) |
Returns the QX11Info structure for the pd paint device. More... | |
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.
When printing directly to a printer on Windows or Mac OS X, QPrinter uses the built-in printer drivers. On X11, QPrinter uses the Common Unix Printing System (CUPS) or the standard Unix lpr utility to send PostScript or PDF output to the printer. As an alternative, the printProgram() function can be used to specify the command or utility to use instead of the system default.
Note that setting parameters like paper size and resolution on an invalid printer is undefined. You can use QPrinter::isValid() to verify this before changing any parameters.
QPrinter supports a number of parameters, most of which can be changed by the end user through a print dialog. In general, QPrinter passes these functions onto the underlying QPrintEngine.
The most important parameters are:
Many of these functions can only be called before the actual printing begins (i.e., before QPainter::begin() is called). This usually makes sense because, for example, it's not possible to change the number of copies when you are halfway through printing. There are also some settings that the user sets (through the printer dialog) and that applications are expected to obey. See QAbstractPrintDialog's documentation for more details.
When QPainter::begin() is called, the QPrinter it operates on is prepared for a new page, enabling the QPainter to be used immediately to paint the first page in a document. Once the first page has been painted, newPage() can be called to request a new blank page to paint on, or QPainter::end() can be called to finish printing. The second page and all following pages are prepared using a call to newPage() before they are painted.
The first page in a document does not need to be preceded by a call to newPage(). You only need to calling newPage() after QPainter::begin() if you need to insert a blank page at the beginning of a printed document. Similarly, calling newPage() after the last page in a document is painted will result in a trailing blank page appended to the end of the printed document.
If you want to abort the print job, abort() will try its best to stop printing. It may cancel the entire job or just part of it.
Since QPrinter can print to any QPrintEngine subclass, it is possible to extend printing support to cover new types of printing subsystem by subclassing QPrintEngine and reimplementing its interface.
Definition at line 66 of file qprinter.h.
enum QPrinter::ColorMode |
This enum type is used to indicate whether QPrinter should print in color or not.
Enumerator | |
---|---|
GrayScale | |
Color |
Definition at line 100 of file qprinter.h.
enum QPrinter::DuplexMode |
This enum is used to indicate whether printing will occur on one or both sides of each sheet of paper (simplex or duplex printing).
Enumerator | |
---|---|
DuplexNone | |
DuplexAuto | |
DuplexLongSide | |
DuplexShortSide |
Definition at line 139 of file qprinter.h.
This enum type (not to be confused with Orientation
) is used to specify each page's orientation.
This type interacts with QPrinter::PaperSize and QPrinter::setFullPage() to determine the final size of the page available to the application.
Enumerator | |
---|---|
Portrait | |
Landscape |
Definition at line 78 of file qprinter.h.
The OutputFormat enum is used to describe the format QPrinter should use for printing.
Enumerator | |
---|---|
NativeFormat | |
PdfFormat | |
PostScriptFormat |
Definition at line 124 of file qprinter.h.
enum QPrinter::PageOrder |
This enum type is used by QPrinter to tell the application program how to print.
Enumerator | |
---|---|
FirstPageFirst | |
LastPageFirst |
Definition at line 97 of file qprinter.h.
enum QPrinter::PageSize |
Use QPrinter::PaperSize instead.
Enumerator | |
---|---|
A4 | |
B5 | |
Letter | |
Legal | |
Executive | |
A0 | |
A1 | |
A2 | |
A3 | |
A5 | |
A6 | |
A7 | |
A8 | |
A9 | |
B0 | |
B1 | |
B10 | |
B2 | |
B3 | |
B4 | |
B6 | |
B7 | |
B8 | |
B9 | |
C5E | |
Comm10E | |
DLE | |
Folio | |
Ledger | |
Tabloid | |
Custom | |
NPageSize |
Definition at line 87 of file qprinter.h.
enum QPrinter::PaperSize |
This enum type specifies what paper size QPrinter should use.
QPrinter does not check that the paper size is available; it just uses this information, together with QPrinter::Orientation and QPrinter::setFullPage(), to determine the printable area.
The defined sizes (with setFullPage(true)) are:
With setFullPage(false) (the default), the metrics will be a bit smaller; how much depends on the printer in use.
Enumerator | |
---|---|
A4 | |
B5 | |
Letter | |
Legal | |
Executive | |
A0 | |
A1 | |
A2 | |
A3 | |
A5 | |
A6 | |
A7 | |
A8 | |
A9 | |
B0 | |
B1 | |
B10 | |
B2 | |
B3 | |
B4 | |
B6 | |
B7 | |
B8 | |
B9 | |
C5E | |
Comm10E | |
DLE | |
Folio | |
Ledger | |
Tabloid | |
Custom | |
NPageSize | |
NPaperSize |
Definition at line 91 of file qprinter.h.
This enum type specifies what paper source QPrinter is to use.
QPrinter does not check that the paper source is available; it just uses this information to try and set the paper source. Whether it will set the paper source depends on whether the printer has that particular source.
Enumerator | |
---|---|
OnlyOne | |
Lower | |
Middle | |
Manual | |
Envelope | |
EnvelopeManual | |
Auto | |
Tractor | |
SmallFormat | |
LargeFormat | |
LargeCapacity | |
Cassette | |
FormSource | |
MaxPageSource |
Definition at line 103 of file qprinter.h.
This enum describes the mode the printer should work in.
It basically presets a certain resolution and working mode.
Enumerator | |
---|---|
ScreenResolution | |
PrinterResolution | |
HighResolution |
Definition at line 70 of file qprinter.h.
Enumerator | |
---|---|
Idle | |
Active | |
Aborted | |
Error |
Definition at line 119 of file qprinter.h.
enum QPrinter::PrintRange |
Used to specify the print range selection option.
Enumerator | |
---|---|
AllPages | |
Selection | |
PageRange | |
CurrentPage |
Definition at line 127 of file qprinter.h.
enum QPrinter::Unit |
This enum type is used to specify the measurement unit for page and paper sizes.
Note the difference between Point and DevicePixel. The Point unit is defined to be 1/72th of an inch, while the DevicePixel unit is resolution dependant and is based on the actual pixels, or dots, on the printer.
Enumerator | |
---|---|
Millimeter | |
Point | |
Inch | |
Pica | |
Didot | |
Cicero | |
DevicePixel |
Definition at line 129 of file qprinter.h.
|
explicit |
Creates a new printer object with the given mode.
Definition at line 632 of file qprinter.cpp.
|
explicit |
Creates a new printer object with the given printer and mode.
Definition at line 655 of file qprinter.cpp.
QPrinter::~QPrinter | ( | ) |
Destroys the printer object and frees any allocated resources.
If the printer is destroyed while a print job is in progress this may or may not affect the print job.
Definition at line 725 of file qprinter.cpp.
bool QPrinter::abort | ( | ) |
Aborts the current print run.
Returns true if the print run was successfully aborted and printerState() will return QPrinter::Aborted; otherwise returns false.
It is not always possible to abort a print job. For example, all the data has gone to the printer but the printer cannot or will not cancel the job when asked to.
Definition at line 1979 of file qprinter.cpp.
int QPrinter::actualNumCopies | ( | ) | const |
Returns the number of copies that will be printed.
The default value is 1.
This function always returns the actual value specified in the print dialog or using setNumCopies().
Use copyCount() instead.
Definition at line 1367 of file qprinter.cpp.
bool QPrinter::collateCopies | ( | ) | const |
Returns true if collation is turned on when multiple copies is selected.
Returns false if it is turned off when multiple copies is selected. When collating is turned off the printing of each individual page will be repeated the numCopies() amount before the next page is started. With collating turned on all pages are printed before the next copy of those pages is started.
Definition at line 1473 of file qprinter.cpp.
Referenced by QPrintDialogPrivate::applyPrinterProperties().
QPrinter::ColorMode QPrinter::colorMode | ( | ) | const |
Returns the current color mode.
Definition at line 1314 of file qprinter.cpp.
Referenced by QPrintDialogPrivate::applyPrinterProperties(), and QPrintDialogPrivate::setPrinter().
int QPrinter::copyCount | ( | ) | const |
Returns the number of copies that will be printed.
The default value is 1.
Definition at line 1430 of file qprinter.cpp.
Referenced by actualNumCopies(), QPrintDialogPrivate::applyPrinterProperties(), setOutputFormat(), and QPrintDialogPrivate::setPrinter().
QString QPrinter::creator | ( | ) | const |
Returns the name of the application that created the document.
Definition at line 1066 of file qprinter.cpp.
|
virtual |
Reimplemented from QPaintDevice.
Definition at line 823 of file qprinter.cpp.
QString QPrinter::docName | ( | ) | const |
Returns the document name.
Definition at line 1035 of file qprinter.cpp.
Referenced by QUnixPrintWidgetPrivate::applyPrinterProperties().
bool QPrinter::doubleSidedPrinting | ( | ) | const |
Returns true if double side printing is enabled.
Currently this option is only supported on X11.
Definition at line 1695 of file qprinter.cpp.
QPrinter::DuplexMode QPrinter::duplex | ( | ) | const |
Returns the current duplex mode.
Currently this option is only supported on X11.
Definition at line 1727 of file qprinter.cpp.
Referenced by QPrintDialogPrivate::applyPrinterProperties(), and doubleSidedPrinting().
bool QPrinter::fontEmbeddingEnabled | ( | ) | const |
Returns true if font embedding is enabled.
Currently this option is only supported on X11.
Definition at line 1642 of file qprinter.cpp.
int QPrinter::fromPage | ( | ) | const |
Returns the number of the first page in a range of pages to be printed (the "from page" setting).
Pages in a document are numbered according to the convention that the first page is page 1.
By default, this function returns a special value of 0, meaning that the "from page" setting is unset.
Definition at line 2168 of file qprinter.cpp.
bool QPrinter::fullPage | ( | ) | const |
Returns true if the origin of the printer's coordinate system is at the corner of the page and false if it is at the edge of the printable area.
See setFullPage() for details and caveats.
Definition at line 1542 of file qprinter.cpp.
Referenced by QTextDocument::print().
|
virtual |
Reimplemented from QPaintDevice.
Definition at line 2054 of file qprinter.cpp.
void QPrinter::getPageMargins | ( | qreal * | left, |
qreal * | top, | ||
qreal * | right, | ||
qreal * | bottom, | ||
QPrinter::Unit | unit | ||
) | const |
Returns the page margins for this printer in left, top, right, bottom.
The unit of the returned margins are specified with the unit parameter.
Definition at line 1853 of file qprinter.cpp.
Referenced by QPageSetupWidget::selectPrinter(), and QPageSetupWidget::setPrinter().
|
private |
Definition at line 663 of file qprinter.cpp.
Referenced by QPrinter().
bool QPrinter::isValid | ( | ) | const |
Returns true if the printer currently selected is a valid printer in the system, or a pure PDF/PostScript printer; otherwise returns false.
To detect other failures check the output of QPainter::begin() or QPrinter::newPage().
Definition at line 895 of file qprinter.cpp.
Referenced by QTextControl::print(), and QTextDocument::print().
|
protectedvirtual |
Returns the metric for the given id.
Reimplemented from QPaintDevice.
Definition at line 1873 of file qprinter.cpp.
bool QPrinter::newPage | ( | ) |
Tells the printer to eject the current page and to continue printing on a new page.
Returns true if this was successful; otherwise returns false.
Calling newPage() on an inactive QPrinter object will always fail.
Definition at line 1962 of file qprinter.cpp.
int QPrinter::numCopies | ( | ) | const |
Returns the number of copies to be printed.
On Windows, Mac OS X and X11 systems that support CUPS, this will always return 1 as these operating systems can internally handle the number of copies.
On X11, this value will return the number of times the application is required to print in order to match the number specified in the printer setup dialog. This has been done since some printer drivers are not capable of buffering up the copies and in those cases the application must make an explicit call to the print code for each copy.
Use copyCount() in conjunction with supportsMultipleCopies() instead.
Definition at line 1343 of file qprinter.cpp.
QPrinter::Orientation QPrinter::orientation | ( | ) | const |
Returns the orientation setting.
This is driver-dependent, but is usually QPrinter::Portrait.
Definition at line 1098 of file qprinter.cpp.
Referenced by paperSize(), QPageSetupWidget::setPrinter(), and QPrintDialogPrivate::setPrinter().
QString QPrinter::outputFileName | ( | ) | const |
Returns the name of the output file.
By default, this is an empty string (indicating that the printer shouldn't print to file).
Definition at line 950 of file qprinter.cpp.
Referenced by QUnixPrintWidgetPrivate::applyPrinterProperties(), printRange(), and QPrintDialogPrivate::setPrinter().
QPrinter::OutputFormat QPrinter::outputFormat | ( | ) | const |
Returns the output format for this printer.
Definition at line 813 of file qprinter.cpp.
Referenced by QUnixPrintWidgetPrivate::applyPrinterProperties(), QAbstractPageSetupDialogPrivate::setPrinter(), QPrintDialog::setVisible(), QUnixPrintWidgetPrivate::updateWidget(), and warnIfNotNative().
QPrinter::PageOrder QPrinter::pageOrder | ( | ) | const |
Returns the current page order.
The default page order is FirstPageFirst
.
Definition at line 1286 of file qprinter.cpp.
Referenced by QPrintDialogPrivate::applyPrinterProperties(), and QPrintDialogPrivate::setPrinter().
QRect QPrinter::pageRect | ( | ) | const |
Returns the page's rectangle; this is usually smaller than the paperRect() since the page normally has margins between its borders and the paper.
The unit of the returned rectangle is DevicePixel.
Definition at line 1800 of file qprinter.cpp.
Returns the page's rectangle in unit; this is usually smaller than the paperRect() since the page normally has margins between its borders and the paper.
Definition at line 1745 of file qprinter.cpp.
QPrinter::PageSize QPrinter::pageSize | ( | ) | const |
Returns the printer page size.
The default value is driver-dependent.
Use paperSize() instead.
Definition at line 1187 of file qprinter.cpp.
Referenced by QPageSetupWidget::_q_paperSizeChanged(), QPrintDialogPrivate::setPrinter(), and QPageSetupWidget::setupPrinter().
|
virtual |
Returns the paint engine used by the printer.
Implements QPaintDevice.
Definition at line 1882 of file qprinter.cpp.
Referenced by QPrintDialog::QPrintDialog(), and setEngines().
QRect QPrinter::paperRect | ( | ) | const |
Returns the paper's rectangle; this is usually larger than the pageRect().
The unit of the returned rectangle is DevicePixel.
Definition at line 1814 of file qprinter.cpp.
Returns the paper's rectangle in unit; this is usually larger than the pageRect().
Definition at line 1774 of file qprinter.cpp.
QPrinter::PaperSize QPrinter::paperSize | ( | ) | const |
Returns the printer paper size.
Definition at line 1140 of file qprinter.cpp.
Referenced by pageSize(), paperSize(), QPageSetupWidget::selectPdfPsPrinter(), QPageSetupWidget::selectPrinter(), and QPageSetupWidget::setPrinter().
Returns the paper size in unit.
Definition at line 1243 of file qprinter.cpp.
QPrinter::PaperSource QPrinter::paperSource | ( | ) | const |
Returns the printer's paper source.
This is Manual
or a printer tray or paper cassette.
Definition at line 1604 of file qprinter.cpp.
Referenced by QPageSetupWidget::setPrinter().
QPrintEngine * QPrinter::printEngine | ( | ) | const |
Returns the print engine used by the printer.
Definition at line 1896 of file qprinter.cpp.
Referenced by QUnixPrintWidgetPrivate::setCupsProperties(), setEngines(), and QPageSetupWidget::setupPrinter().
QString QPrinter::printerName | ( | ) | const |
Returns the printer name.
This value is initially set to the name of the default printer.
Definition at line 834 of file qprinter.cpp.
Referenced by QUnixPrintWidgetPrivate::applyPrinterProperties(), QPrinterInfo::QPrinterInfo(), setPrinterName(), and QUnixPrintWidgetPrivate::updateWidget().
QString QPrinter::printerSelectionOption | ( | ) | const |
Returns the printer options selection string.
This is useful only if the print command has been explicitly set.
The default value (an empty string) implies that the printer should be selected in a system-dependent manner.
Any other value implies that the given value should be used.
Referenced by supportedPaperSources().
QPrinter::PrinterState QPrinter::printerState | ( | ) | const |
Returns the current state of the printer.
This may not always be accurate (for example if the printer doesn't have the capability of reporting its state to the operating system).
Definition at line 1990 of file qprinter.cpp.
QString QPrinter::printProgram | ( | ) | const |
Returns the name of the program that sends the print output to the printer.
The default is to return an empty string; meaning that QPrinter will try to be smart in a system-dependent way. On X11 only, you can set it to something different to use a specific print program. On the other platforms, this returns an empty string.
Definition at line 1005 of file qprinter.cpp.
QPrinter::PrintRange QPrinter::printRange | ( | ) | const |
Returns the page range of the QPrinter.
After the print setup dialog has been opened, this function returns the value selected by the user.
Definition at line 2265 of file qprinter.cpp.
Referenced by QTextControl::print().
|
virtual |
Reimplemented from QPaintDevice.
Definition at line 2063 of file qprinter.cpp.
int QPrinter::resolution | ( | ) | const |
Returns the current assumed resolution of the printer, as set by setResolution() or by the printer driver.
Definition at line 1578 of file qprinter.cpp.
Referenced by getPageMargins(), pageRect(), paperRect(), paperSize(), setPageMargins(), and setPaperSize().
void QPrinter::setCollateCopies | ( | bool | collate | ) |
Sets the default value for collation checkbox when the print dialog appears.
If collate is true, it will enable setCollateCopiesEnabled(). The default value is false. This value will be changed by what the user presses in the print dialog.
Definition at line 1493 of file qprinter.cpp.
Referenced by QPrintDialogPrivate::setupPrinter().
void QPrinter::setColorMode | ( | ColorMode | newColorMode | ) |
Sets the printer's color mode to newColorMode, which can be either Color
or GrayScale
.
Definition at line 1300 of file qprinter.cpp.
Referenced by QPrintDialogPrivate::_q_okClicked(), and QPrintDialogPrivate::setupPrinter().
void QPrinter::setCopyCount | ( | int | count | ) |
Sets the number of copies to be printed to count.
The printer driver reads this setting and prints the specified number of copies.
Definition at line 1411 of file qprinter.cpp.
Referenced by QPrintDialogPrivate::_q_okClicked(), and QPrintDialogPrivate::setupPrinter().
void QPrinter::setCreator | ( | const QString & | creator | ) |
Sets the name of the application that created the document to creator.
This function is only applicable to the X11 version of Qt. If no creator name is specified, the creator will be set to "Qt" followed by some version number.
Definition at line 1083 of file qprinter.cpp.
void QPrinter::setDocName | ( | const QString & | name | ) |
Sets the document name to name.
On X11, the document name is for example used as the default output filename in QPrintDialog. Note that the document name does not affect the file name if the printer is printing to a file. Use the setOutputFile() function for this.
Definition at line 1052 of file qprinter.cpp.
Referenced by QTextDocument::print().
void QPrinter::setDoubleSidedPrinting | ( | bool | doubleSided | ) |
Enables double sided printing if doubleSided is true; otherwise disables it.
Currently this option is only supported on X11.
Definition at line 1679 of file qprinter.cpp.
void QPrinter::setDuplex | ( | DuplexMode | duplex | ) |
Enables double sided printing based on the duplex mode.
Currently this option is only supported on X11.
Definition at line 1710 of file qprinter.cpp.
Referenced by setDoubleSidedPrinting(), and QPrintDialogPrivate::setupPrinter().
|
protected |
This function is used by subclasses of QPrinter to specify custom print and paint engines (printEngine and paintEngine, respectively).
QPrinter does not take ownership of the engines, so you need to manage these engine instances yourself.
Note that changing the engines will reset the printer state and all its properties.
Definition at line 708 of file qprinter.cpp.
void QPrinter::setFontEmbeddingEnabled | ( | bool | enable | ) |
Enabled or disables font embedding depending on enable.
Currently this option is only supported on X11.
Definition at line 1623 of file qprinter.cpp.
void QPrinter::setFromTo | ( | int | from, |
int | to | ||
) |
Sets the range of pages to be printed to cover the pages with numbers specified by from and to, where from corresponds to the first page in the range and to corresponds to the last.
This function is mostly used to set a default value that the user can override in the print dialog when you call setup().
Definition at line 2222 of file qprinter.cpp.
Referenced by QPrintDialogPrivate::setupPrinter().
void QPrinter::setFullPage | ( | bool | fp | ) |
If fp is true, enables support for painting over the entire page; otherwise restricts painting to the printable area reported by the device.
By default, full page printing is disabled. In this case, the origin of the QPrinter's coordinate system coincides with the top-left corner of the printable area.
If full page printing is enabled, the origin of the QPrinter's coordinate system coincides with the top-left corner of the paper itself. In this case, the device metrics will report the exact same dimensions as indicated by PaperSize. It may not be possible to print on the entire physical page because of the printer's margins, so the application must account for the margins itself.
Definition at line 1524 of file qprinter.cpp.
void QPrinter::setNumCopies | ( | int | numCopies | ) |
Sets the number of copies to be printed to numCopies.
The printer driver reads this setting and prints the specified number of copies.
Use setCopyCount() instead.
Definition at line 1389 of file qprinter.cpp.
void QPrinter::setOrientation | ( | Orientation | orientation | ) |
Sets the print orientation to orientation.
The orientation can be either QPrinter::Portrait or QPrinter::Landscape.
The printer driver reads this setting and prints using the specified orientation.
On Windows, this option can be changed while printing and will take effect from the next call to newPage().
On Mac OS X, changing the orientation during a print job has no effect.
Definition at line 1122 of file qprinter.cpp.
Referenced by QPrintDialogPrivate::_q_okClicked(), and QPageSetupWidget::setupPrinter().
void QPrinter::setOutputFileName | ( | const QString & | fileName | ) |
Sets the name of the output file to fileName.
Setting a null or empty name (0 or "") disables printing to a file. Setting a non-empty name enables printing to a file.
This can change the value of outputFormat(). If the file name has the suffix ".ps" then PostScript is automatically selected as output format. If the file name has the ".pdf" suffix PDF is generated. If the file name has a suffix other than ".ps" and ".pdf", the output format used is the one set with setOutputFormat().
QPrinter uses Qt's cross-platform PostScript or PDF print engines respectively. If you can produce this format natively, for example Mac OS X can generate PDF's from its print engine, set the output format back to NativeFormat.
Definition at line 976 of file qprinter.cpp.
Referenced by QPrintDialogPrivate::_q_okClicked(), printRange(), and QUnixPrintWidgetPrivate::setupPrinter().
void QPrinter::setOutputFormat | ( | OutputFormat | format | ) |
Sets the output format for this printer to format.
Definition at line 765 of file qprinter.cpp.
Referenced by init(), QPrinter(), setOutputFileName(), setPrinterName(), and QUnixPrintWidgetPrivate::setupPrinter().
void QPrinter::setPageMargins | ( | qreal | left, |
qreal | top, | ||
qreal | right, | ||
qreal | bottom, | ||
QPrinter::Unit | unit | ||
) |
This function sets the left, top, right and bottom page margins for this printer.
The unit of the margins are specified with the unit parameter.
Definition at line 1831 of file qprinter.cpp.
Referenced by QTextDocument::print(), and QPageSetupWidget::setupPrinter().
void QPrinter::setPageOrder | ( | PageOrder | pageOrder | ) |
Sets the page order to pageOrder.
The page order can be QPrinter::FirstPageFirst or QPrinter::LastPageFirst. The application is responsible for reading the page order and printing accordingly.
This function is mostly useful for setting a default value that the user can override in the print dialog.
This function is only supported under X11.
Definition at line 1271 of file qprinter.cpp.
Referenced by QPrintDialogPrivate::_q_okClicked().
void QPrinter::setPageSize | ( | PageSize | newPageSize | ) |
Sets the printer page size based on newPageSize.
Use setPaperSize() instead.
Definition at line 1204 of file qprinter.cpp.
void QPrinter::setPaperSize | ( | PaperSize | newPaperSize | ) |
Sets the printer paper size to newPaperSize if that size is supported.
The result is undefined if newPaperSize is not supported.
The default paper size is driver-dependent.
This function is useful mostly for setting a default value that the user can override in the print dialog.
Definition at line 1163 of file qprinter.cpp.
Referenced by QPrintDialogPrivate::_q_okClicked(), QUnixPrintWidgetPrivate::setCupsProperties(), setPageSize(), and QPageSetupWidget::setupPrinter().
void QPrinter::setPaperSize | ( | const QSizeF & | paperSize, |
QPrinter::Unit | unit | ||
) |
Sets the paper size based on paperSize in unit.
Definition at line 1220 of file qprinter.cpp.
void QPrinter::setPaperSource | ( | PaperSource | source | ) |
Sets the paper source setting to source.
Windows only: This option can be changed while printing and will take effect from the next call to newPage()
Definition at line 1593 of file qprinter.cpp.
Referenced by QPageSetupWidget::setupPrinter().
void QPrinter::setPrinterName | ( | const QString & | name | ) |
Sets the printer name to name.
Definition at line 845 of file qprinter.cpp.
Referenced by QPrinter(), and QUnixPrintWidgetPrivate::setupPrinter().
void QPrinter::setPrinterSelectionOption | ( | const QString & | option | ) |
Sets the printer to use option to select the printer.
option is null by default (which implies that Qt should be smart enough to guess correctly), but it can be set to other values to use a specific printer selection option.
If the printer selection option is changed while the printer is active, the current print job may or may not be affected.
Referenced by supportedPaperSources().
void QPrinter::setPrintProgram | ( | const QString & | printProg | ) |
Sets the name of the program that should do the print job to printProg.
On X11, this function sets the program to call with the PostScript output. On other platforms, it has no effect.
Definition at line 1021 of file qprinter.cpp.
void QPrinter::setPrintRange | ( | PrintRange | range | ) |
Sets the print range option in to be range.
Definition at line 2247 of file qprinter.cpp.
Referenced by QPrintDialogPrivate::setupPrinter().
void QPrinter::setResolution | ( | int | dpi | ) |
Requests that the printer prints at dpi or as near to dpi as possible.
This setting affects the coordinate system as returned by, for example QPainter::viewport().
This function must be called before QPainter::begin() to have an effect on all platforms.
Definition at line 1562 of file qprinter.cpp.
void QPrinter::setWinPageSize | ( | int | pageSize | ) |
Sets the page size to be used by the printer under Windows to pageSize.
Definition at line 1912 of file qprinter.cpp.
QList< QPrinter::PaperSource > QPrinter::supportedPaperSources | ( | ) | const |
Returns the supported paper sizes for this printer.
The values will be either a value that matches an entry in the QPrinter::PaperSource enum or a driver spesific value. The driver spesific values are greater than the constant DMBIN_USER declared in wingdi.h.
Definition at line 2080 of file qprinter.cpp.
QList< int > QPrinter::supportedResolutions | ( | ) | const |
Returns a list of the resolutions (a list of dots-per-inch integers) that the printer says it supports.
For X11 where all printing is directly to postscript, this function will always return a one item list containing only the postscript resolution, i.e., 72 (72 dpi – but see PrinterMode).
Definition at line 1943 of file qprinter.cpp.
bool QPrinter::supportsMultipleCopies | ( | ) | const |
Returns true if the printer supports printing multiple copies of the same document in one job; otherwise false is returned.
On most systems this function will return true. However, on X11 systems that do not support CUPS, this function will return false. That means the application has to handle the number of copies by printing the same document the required number of times.
Definition at line 1453 of file qprinter.cpp.
int QPrinter::toPage | ( | ) | const |
Returns the number of the last page in a range of pages to be printed (the "to page" setting).
Pages in a document are numbered according to the convention that the first page is page 1.
By default, this function returns a special value of 0, meaning that the "to page" setting is unset.
The programmer is responsible for reading this setting and printing accordingly.
Definition at line 2196 of file qprinter.cpp.
int QPrinter::winPageSize | ( | ) | const |
Returns the page size used by the printer under Windows.
Definition at line 1928 of file qprinter.cpp.
|
friend |
Definition at line 301 of file qprinter.h.
|
friend |
Definition at line 302 of file qprinter.h.
|
friend |
Definition at line 305 of file qprinter.h.
|
friend |
Definition at line 300 of file qprinter.h.
|
friend |
Definition at line 303 of file qprinter.h.
|
friend |
Definition at line 304 of file qprinter.h.
|
private |
Definition at line 298 of file qprinter.h.
Referenced by QPrinter().