📄 qprinter.3qt
字号:
'\" t.TH QPrinter 3qt "10 November 2003" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQPrinter \- Paint device that paints on a printer.SH SYNOPSIS\fC#include <qprinter.h>\fR.PPInherits QPaintDevice..PP.SS "Public Members".in +1c.ti -1c.BI "enum \fBPrinterMode\fR { ScreenResolution, PrinterResolution, HighResolution, Compatible }".br.ti -1c.BI "\fBQPrinter\fR ( PrinterMode m = ScreenResolution )".br.ti -1c.BI "\fB~QPrinter\fR ()".br.ti -1c.BI "enum \fBOrientation\fR { Portrait, Landscape }".br.ti -1c.BI "enum \fBPageSize\fR { 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 }".br.ti -1c.BI "enum \fBPageOrder\fR { FirstPageFirst, LastPageFirst }".br.ti -1c.BI "enum \fBColorMode\fR { GrayScale, Color }".br.ti -1c.BI "enum \fBPaperSource\fR { OnlyOne, Lower, Middle, Manual, Envelope, EnvelopeManual, Auto, Tractor, SmallFormat, LargeFormat, LargeCapacity, Cassette, FormSource }".br.ti -1c.BI "enum \fBPrintRange\fR { AllPages, Selection, PageRange }".br.ti -1c.BI "enum \fBPrinterOption\fR { PrintToFile, PrintSelection, PrintPageRange }".br.ti -1c.BI "QString \fBprinterName\fR () const".br.ti -1c.BI "virtual void \fBsetPrinterName\fR ( const QString & name )".br.ti -1c.BI "bool \fBoutputToFile\fR () const".br.ti -1c.BI "virtual void \fBsetOutputToFile\fR ( bool enable )".br.ti -1c.BI "QString \fBoutputFileName\fR () const".br.ti -1c.BI "virtual void \fBsetOutputFileName\fR ( const QString & fileName )".br.ti -1c.BI "QString \fBprintProgram\fR () const".br.ti -1c.BI "virtual void \fBsetPrintProgram\fR ( const QString & printProg )".br.ti -1c.BI "QString \fBprinterSelectionOption\fR () const".br.ti -1c.BI "virtual void \fBsetPrinterSelectionOption\fR ( const QString & option )".br.ti -1c.BI "QString \fBdocName\fR () const".br.ti -1c.BI "virtual void \fBsetDocName\fR ( const QString & name )".br.ti -1c.BI "QString \fBcreator\fR () const".br.ti -1c.BI "virtual void \fBsetCreator\fR ( const QString & creator )".br.ti -1c.BI "Orientation \fBorientation\fR () const".br.ti -1c.BI "virtual void \fBsetOrientation\fR ( Orientation orientation )".br.ti -1c.BI "PageSize \fBpageSize\fR () const".br.ti -1c.BI "virtual void \fBsetPageSize\fR ( PageSize newPageSize )".br.ti -1c.BI "void \fBsetWinPageSize\fR ( short winPageSize )".br.ti -1c.BI "short \fBwinPageSize\fR () const".br.ti -1c.BI "virtual void \fBsetPageOrder\fR ( PageOrder newPageOrder )".br.ti -1c.BI "PageOrder \fBpageOrder\fR () const".br.ti -1c.BI "virtual void \fBsetResolution\fR ( int dpi )".br.ti -1c.BI "virtual int \fBresolution\fR () const".br.ti -1c.BI "virtual void \fBsetColorMode\fR ( ColorMode newColorMode )".br.ti -1c.BI "ColorMode \fBcolorMode\fR () const".br.ti -1c.BI "virtual void \fBsetFullPage\fR ( bool fp )".br.ti -1c.BI "bool \fBfullPage\fR () const".br.ti -1c.BI "QSize \fBmargins\fR () const".br.ti -1c.BI "void \fBsetMargins\fR ( uint top, uint left, uint bottom, uint right )".br.ti -1c.BI "void \fBmargins\fR ( uint * top, uint * left, uint * bottom, uint * right ) const".br.ti -1c.BI "int \fBfromPage\fR () const".br.ti -1c.BI "int \fBtoPage\fR () const".br.ti -1c.BI "virtual void \fBsetFromTo\fR ( int fromPage, int toPage )".br.ti -1c.BI "int \fBminPage\fR () const".br.ti -1c.BI "int \fBmaxPage\fR () const".br.ti -1c.BI "virtual void \fBsetMinMax\fR ( int minPage, int maxPage )".br.ti -1c.BI "int \fBnumCopies\fR () const".br.ti -1c.BI "virtual void \fBsetNumCopies\fR ( int numCopies )".br.ti -1c.BI "PrintRange \fBprintRange\fR () const".br.ti -1c.BI "void \fBsetPrintRange\fR ( PrintRange range )".br.ti -1c.BI "bool \fBnewPage\fR ()".br.ti -1c.BI "bool \fBabort\fR ()".br.ti -1c.BI "bool \fBaborted\fR () const".br.ti -1c.BI "bool \fBsetup\fR ( QWidget * parent = 0 )".br.ti -1c.BI "PaperSource \fBpaperSource\fR () const".br.ti -1c.BI "virtual void \fBsetPaperSource\fR ( PaperSource source )".br.ti -1c.BI "void \fBsetOptionEnabled\fR ( PrinterOption option, bool enable )".br.ti -1c.BI "bool \fBisOptionEnabled\fR ( PrinterOption option )".br.in -1c.SH DESCRIPTIONThe QPrinter class is a paint device that paints on a printer..PPOn Windows it uses the built-in printer drivers. On X11 it generates postscript and sends that to lpr, lp, or another print command..PPQPrinter is used in much the same way as QWidget and QPixmap are used. The big difference is that you must keep track of the pages..PPQPrinter supports a number of settable parameters, most of which can be changed by the end user when the application calls QPrinter::setup()..PPThe most important parameters are:.TPsetOrientation() tells QPrinter which page orientation to use (virtual)..TPsetPageSize() tells QPrinter what page size to expect from the printer..TPsetResolution() tells QPrinter what resolution you wish the printer to provide (in dpi)..TPsetFullPage() tells QPrinter whether you want to deal with the full page or just with the part the printer can draw on. The default is FALSE, so that by default you should be able to paint on (0,0). If TRUE the origin of the coordinate system will be in the top left corner of the paper and most probably the printer will not be able to paint something there due to it's physical margins..TPsetNumCopies() tells QPrinter how many copies of the document it should print..TPsetMinMax() tells QPrinter and QPrintDialog what the allowed range for fromPage() and toPage() are..PPExcept where noted, you can only call the set functions before setup(), or between QPainter::end() and setup(). (Some may take effect between setup() and begin(), or between begin() and end(), but that's strictly undocumented and such behaviour may differ depending on platform.).PPThere are also some settings that the user sets (through the printer dialog) and that applications are expected to obey:.IP.TPpageOrder() tells the application program whether to print first-page-first or last-page-first..IP.TPcolorMode() tells the application program whether to print in color or grayscale. (If you print in color and the printer does not support color, Qt will try to approximate. The document may take longer to print, but the quality should not be made visibly poorer.).IP.TPfromPage() and toPage() indicate what pages the application program should print..IP.TPpaperSource() tells the application progam which paper source to print from..IP.PPYou can of course call these functions to establish defaults before you ask the user through QPrinter::setup()..PPOnce you start printing, calling newPage() is essential. You will probably also need to look at the QPaintDeviceMetrics for the printer (see the print function in the Application walk-through). Note that the paint device metrics are valid only after the QPrinter has been set up, i.e. after setup() has returned successfully..PPIf you want to abort the print job, abort() will try its best to stop printing. It may cancel the entire job or just some of it..PPIf your current locale converts "," to ".", you will need to set a locale that doen't do this (e.g. the "C" locale) before using QPrinter..PP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -