qprinter.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/printsupport/kernel/qprinter.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qprinter.h"-
35#include "qprinter_p.h"-
36-
37#ifndef QT_NO_PRINTER-
38-
39#include <qpa/qplatformprintplugin.h>-
40#include <qpa/qplatformprintersupport.h>-
41-
42#include "qprintengine.h"-
43#include "qlist.h"-
44#include <qcoreapplication.h>-
45#include <qfileinfo.h>-
46-
47#include <private/qpagedpaintdevice_p.h>-
48-
49#include "qprintengine_pdf_p.h"-
50-
51#include <qpicture.h>-
52#include <private/qpaintengine_preview_p.h>-
53-
54QT_BEGIN_NAMESPACE-
55-
56#define ABORT_IF_ACTIVE(location) \-
57 if (d->printEngine->printerState() == QPrinter::Active) { \-
58 qWarning("%s: Cannot be changed while printer is active", location); \-
59 return; \-
60 }-
61-
62#define ABORT_IF_ACTIVE_RETURN(location, retValue) \-
63 if (d->printEngine->printerState() == QPrinter::Active) { \-
64 qWarning("%s: Cannot be changed while printer is active", location); \-
65 return retValue; \-
66 }-
67-
68extern qreal qt_pixelMultiplier(int resolution);-
69extern QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits);-
70-
71/// return the multiplier of converting from the unit value to postscript-points.-
72Q_PRINTSUPPORT_EXPORT double qt_multiplierForUnit(QPrinter::Unit unit, int resolution)-
73{-
74 switch(unit) {-
75 case QPrinter::Millimeter:
never executed: case QPrinter::Millimeter:
0
76 return 2.83464566929;
never executed: return 2.83464566929;
0
77 case QPrinter::Point:
never executed: case QPrinter::Point:
0
78 return 1.0;
never executed: return 1.0;
0
79 case QPrinter::Inch:
never executed: case QPrinter::Inch:
0
80 return 72.0;
never executed: return 72.0;
0
81 case QPrinter::Pica:
never executed: case QPrinter::Pica:
0
82 return 12;
never executed: return 12;
0
83 case QPrinter::Didot:
never executed: case QPrinter::Didot:
0
84 return 1.065826771;
never executed: return 1.065826771;
0
85 case QPrinter::Cicero:
never executed: case QPrinter::Cicero:
0
86 return 12.789921252;
never executed: return 12.789921252;
0
87 case QPrinter::DevicePixel:
never executed: case QPrinter::DevicePixel:
0
88 return 72.0/resolution;
never executed: return 72.0/resolution;
0
89 }-
90 return 1.0;
never executed: return 1.0;
0
91}-
92-
93// not static: it's needed in qpagesetupdialog_unix.cpp-
94Q_PRINTSUPPORT_EXPORT QSizeF qt_printerPaperSize(QPrinter::Orientation orientation,-
95 QPrinter::PaperSize paperSize,-
96 QPrinter::Unit unit,-
97 int resolution)-
98{-
99 QPageSize pageSize = QPageSize(QPageSize::PageSizeId(paperSize));-
100 QSizeF sizef;-
101 if (unit == QPrinter::DevicePixel)
unit == QPrinter::DevicePixelDescription
TRUEnever evaluated
FALSEnever evaluated
0
102 sizef = pageSize.size(QPageSize::Point) * qt_multiplierForUnit(unit, resolution);
never executed: sizef = pageSize.size(QPageSize::Point) * qt_multiplierForUnit(unit, resolution);
0
103 else-
104 sizef = pageSize.size(QPageSize::Unit(unit));
never executed: sizef = pageSize.size(QPageSize::Unit(unit));
0
105 return orientation == QPrinter::Landscape ? sizef.transposed() : sizef;
never executed: return orientation == QPrinter::Landscape ? sizef.transposed() : sizef;
orientation ==...ter::LandscapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
106}-
107-
108QPrinterInfo QPrinterPrivate::findValidPrinter(const QPrinterInfo &printer)-
109{-
110 // Try find a valid printer to use, either the one given, the default or the first available-
111 QPrinterInfo printerToUse = printer;-
112 if (printerToUse.isNull()) {
printerToUse.isNull()Description
TRUEevaluated 134 times by 2 tests
Evaluated by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
FALSEnever evaluated
0-134
113 printerToUse = QPrinterInfo::defaultPrinter();-
114 if (printerToUse.isNull()) {
printerToUse.isNull()Description
TRUEevaluated 134 times by 2 tests
Evaluated by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
FALSEnever evaluated
0-134
115 QStringList availablePrinterNames = QPrinterInfo::availablePrinterNames();-
116 if (!availablePrinterNames.isEmpty())
!availablePrin...ames.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 134 times by 2 tests
Evaluated by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
0-134
117 printerToUse = QPrinterInfo::printerInfo(availablePrinterNames.at(0));
never executed: printerToUse = QPrinterInfo::printerInfo(availablePrinterNames.at(0));
0
118 }
executed 134 times by 2 tests: end of block
Executed by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
134
119 }
executed 134 times by 2 tests: end of block
Executed by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
134
120 return printerToUse;
executed 134 times by 2 tests: return printerToUse;
Executed by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
134
121}-
122-
123void QPrinterPrivate::initEngines(QPrinter::OutputFormat format, const QPrinterInfo &printer)-
124{-
125 // Default to PdfFormat-
126 outputFormat = QPrinter::PdfFormat;-
127 QPlatformPrinterSupport *ps = 0;-
128 QString printerName;-
129-
130 // Only set NativeFormat if we have a valid plugin and printer to use-
131 if (format == QPrinter::NativeFormat) {
format == QPri...::NativeFormatDescription
TRUEevaluated 128 times by 2 tests
Evaluated by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
FALSEnever evaluated
0-128
132 ps = QPlatformPrinterSupportPlugin::get();-
133 QPrinterInfo printerToUse = findValidPrinter(printer);-
134 if (ps && !printerToUse.isNull()) {
psDescription
TRUEevaluated 128 times by 2 tests
Evaluated by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
FALSEnever evaluated
!printerToUse.isNull()Description
TRUEnever evaluated
FALSEevaluated 128 times by 2 tests
Evaluated by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
0-128
135 outputFormat = QPrinter::NativeFormat;-
136 printerName = printerToUse.printerName();-
137 }
never executed: end of block
0
138 }
executed 128 times by 2 tests: end of block
Executed by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
128
139-
140 if (outputFormat == QPrinter::NativeFormat) {
outputFormat =...::NativeFormatDescription
TRUEnever evaluated
FALSEevaluated 128 times by 2 tests
Evaluated by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
0-128
141 printEngine = ps->createNativePrintEngine(printerMode);-
142 paintEngine = ps->createPaintEngine(printEngine, printerMode);-
143 } else {
never executed: end of block
0
144 QPdfPrintEngine *pdfEngine = new QPdfPrintEngine(printerMode);-
145 paintEngine = pdfEngine;-
146 printEngine = pdfEngine;-
147 }
executed 128 times by 2 tests: end of block
Executed by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
128
148-
149 use_default_engine = true;-
150 had_default_engines = true;-
151 setProperty(QPrintEngine::PPK_PrinterName, printerName);-
152 validPrinter = true;-
153}
executed 128 times by 2 tests: end of block
Executed by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
128
154-
155void QPrinterPrivate::changeEngines(QPrinter::OutputFormat format, const QPrinterInfo &printer)-
156{-
157 QPrintEngine *oldPrintEngine = printEngine;-
158 const bool def_engine = use_default_engine;-
159-
160 initEngines(format, printer);-
161-
162 if (oldPrintEngine) {
oldPrintEngineDescription
TRUEnever evaluated
FALSEnever evaluated
0
163 foreach (QPrintEngine::PrintEnginePropertyKey key, m_properties) {-
164 QVariant prop;-
165 // PPK_NumberOfCopies need special treatmeant since it in most cases-
166 // will return 1, disregarding the actual value that was set-
167 // PPK_PrinterName also needs special treatment as initEngines has set it already-
168 if (key == QPrintEngine::PPK_NumberOfCopies)
key == QPrintE...NumberOfCopiesDescription
TRUEnever evaluated
FALSEnever evaluated
0
169 prop = QVariant(q_ptr->copyCount());
never executed: prop = QVariant(q_ptr->copyCount());
0
170 else if (key != QPrintEngine::PPK_PrinterName)
key != QPrintE...PK_PrinterNameDescription
TRUEnever evaluated
FALSEnever evaluated
0
171 prop = oldPrintEngine->property(key);
never executed: prop = oldPrintEngine->property(key);
0
172 if (prop.isValid())
prop.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
173 setProperty(key, prop);
never executed: setProperty(key, prop);
0
174 }
never executed: end of block
0
175 }
never executed: end of block
0
176-
177 if (def_engine)
def_engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
178 delete oldPrintEngine;
never executed: delete oldPrintEngine;
0
179}
never executed: end of block
0
180-
181#ifndef QT_NO_PRINTPREVIEWWIDGET-
182QList<const QPicture *> QPrinterPrivate::previewPages() const-
183{-
184 if (previewEngine)
previewEngineDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-1
185 return previewEngine->pages();
executed 1 time by 1 test: return previewEngine->pages();
Executed by:
  • tst_QPrinter
1
186 return QList<const QPicture *>();
never executed: return QList<const QPicture *>();
0
187}-
188-
189void QPrinterPrivate::setPreviewMode(bool enable)-
190{-
191 Q_Q(QPrinter);-
192 if (enable) {
enableDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
1
193 if (!previewEngine)
!previewEngineDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-1
194 previewEngine = new QPreviewPaintEngine;
executed 1 time by 1 test: previewEngine = new QPreviewPaintEngine;
Executed by:
  • tst_QPrinter
1
195 had_default_engines = use_default_engine;-
196 use_default_engine = false;-
197 realPrintEngine = printEngine;-
198 realPaintEngine = paintEngine;-
199 q->setEngines(previewEngine, previewEngine);-
200 previewEngine->setProxyEngines(realPrintEngine, realPaintEngine);-
201 } else {
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
202 q->setEngines(realPrintEngine, realPaintEngine);-
203 use_default_engine = had_default_engines;-
204 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
205}-
206#endif // QT_NO_PRINTPREVIEWWIDGET-
207-
208void QPrinterPrivate::setProperty(QPrintEngine::PrintEnginePropertyKey key, const QVariant &value)-
209{-
210 printEngine->setProperty(key, value);-
211 m_properties.insert(key);-
212}
executed 336 times by 2 tests: end of block
Executed by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
336
213-
214-
215class QPrinterPagedPaintDevicePrivate : public QPagedPaintDevicePrivate-
216{-
217public:-
218 QPrinterPagedPaintDevicePrivate(QPrinterPrivate *d)-
219 : QPagedPaintDevicePrivate(), pd(d)-
220 {}
executed 128 times by 2 tests: end of block
Executed by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
128
221-
222 virtual ~QPrinterPagedPaintDevicePrivate()-
223 {}-
224-
225 bool setPageLayout(const QPageLayout &newPageLayout) Q_DECL_OVERRIDE-
226 {-
227 if (pd->paintEngine->type() != QPaintEngine::Pdf
pd->paintEngin...intEngine::PdfDescription
TRUEnever evaluated
FALSEnever evaluated
0
228 && pd->printEngine->printerState() == QPrinter::Active) {
pd->printEngin...rinter::ActiveDescription
TRUEnever evaluated
FALSEnever evaluated
0
229 qWarning("QPrinter::setPageLayout: Cannot be changed while printer is active");-
230 return false;
never executed: return false;
0
231 }-
232-
233 // Try to set the print engine page layout-
234 pd->setProperty(QPrintEngine::PPK_QPageLayout, QVariant::fromValue(newPageLayout));-
235-
236 // Set QPagedPaintDevice layout to match the current print engine value-
237 m_pageLayout = pageLayout();-
238-
239 return pageLayout().isEquivalentTo(newPageLayout);
never executed: return pageLayout().isEquivalentTo(newPageLayout);
0
240 }-
241-
242 bool setPageSize(const QPageSize &pageSize) Q_DECL_OVERRIDE-
243 {-
244 if (pd->paintEngine->type() != QPaintEngine::Pdf
pd->paintEngin...intEngine::PdfDescription
TRUEnever evaluated
FALSEevaluated 47 times by 1 test
Evaluated by:
  • tst_QPrinter
0-47
245 && pd->printEngine->printerState() == QPrinter::Active) {
pd->printEngin...rinter::ActiveDescription
TRUEnever evaluated
FALSEnever evaluated
0
246 qWarning("QPrinter::setPageLayout: Cannot be changed while printer is active");-
247 return false;
never executed: return false;
0
248 }-
249-
250-
251 // Try to set the print engine page size-
252 pd->setProperty(QPrintEngine::PPK_QPageSize, QVariant::fromValue(pageSize));-
253-
254 // Set QPagedPaintDevice layout to match the current print engine value-
255 m_pageLayout = pageLayout();-
256-
257 return pageLayout().pageSize().isEquivalentTo(pageSize);
executed 47 times by 1 test: return pageLayout().pageSize().isEquivalentTo(pageSize);
Executed by:
  • tst_QPrinter
47
258 }-
259-
260 bool setPageOrientation(QPageLayout::Orientation orientation) Q_DECL_OVERRIDE-
261 {-
262 // Set the print engine value-
263 pd->setProperty(QPrintEngine::PPK_Orientation, orientation);-
264-
265 // Set QPagedPaintDevice layout to match the current print engine value-
266 m_pageLayout = pageLayout();-
267-
268 return pageLayout().orientation() == orientation;
executed 48 times by 1 test: return pageLayout().orientation() == orientation;
Executed by:
  • tst_QPrinter
48
269 }-
270-
271 bool setPageMargins(const QMarginsF &margins) Q_DECL_OVERRIDE-
272 {-
273 return setPageMargins(margins, pageLayout().units());
never executed: return setPageMargins(margins, pageLayout().units());
0
274 }-
275-
276 bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units) Q_DECL_OVERRIDE-
277 {-
278 // Try to set print engine margins-
279 QPair<QMarginsF, QPageLayout::Unit> pair = qMakePair(margins, units);-
280 pd->setProperty(QPrintEngine::PPK_QPageMargins, QVariant::fromValue(pair));-
281-
282 // Set QPagedPaintDevice layout to match the current print engine value-
283 m_pageLayout = pageLayout();-
284-
285 return pageLayout().margins() == margins && pageLayout().units() == units;
executed 13 times by 1 test: return pageLayout().margins() == margins && pageLayout().units() == units;
Executed by:
  • tst_QPrinter
pageLayout().m...s() == marginsDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
pageLayout().units() == unitsDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-13
286 }-
287-
288 QPageLayout pageLayout() const Q_DECL_OVERRIDE-
289 {-
290 return pd->printEngine->property(QPrintEngine::PPK_QPageLayout).value<QPageLayout>();
executed 462 times by 1 test: return pd->printEngine->property(QPrintEngine::PPK_QPageLayout).value<QPageLayout>();
Executed by:
  • tst_QPrinter
462
291 }-
292-
293 QPrinterPrivate *pd;-
294};-
295-
296-
297/*!-
298 \class QPrinter-
299 \reentrant-
300-
301 \brief The QPrinter class is a paint device that paints on a printer.-
302-
303 \ingroup printing-
304 \inmodule QtPrintSupport-
305-
306-
307 This device represents a series of pages of printed output, and is-
308 used in almost exactly the same way as other paint devices such as-
309 QWidget and QPixmap.-
310 A set of additional functions are provided to manage device-specific-
311 features, such as orientation and resolution, and to step through-
312 the pages in a document as it is generated.-
313-
314 When printing directly to a printer on Windows or \macos, QPrinter uses-
315 the built-in printer drivers. On X11, QPrinter uses the-
316 \l{Common Unix Printing System (CUPS)}-
317 to send PDF output to the printer. As an alternative,-
318 the printProgram() function can be used to specify the command or utility-
319 to use instead of the system default.-
320-
321 Note that setting parameters like paper size and resolution on an-
322 invalid printer is undefined. You can use QPrinter::isValid() to-
323 verify this before changing any parameters.-
324-
325 QPrinter supports a number of parameters, most of which can be-
326 changed by the end user through a \l{QPrintDialog}{print dialog}. In-
327 general, QPrinter passes these functions onto the underlying QPrintEngine.-
328-
329 The most important parameters are:-
330 \list-
331 \li setOrientation() tells QPrinter which page orientation to use.-
332 \li setPaperSize() tells QPrinter what paper size to expect from the-
333 printer.-
334 \li setResolution() tells QPrinter what resolution you wish the-
335 printer to provide, in dots per inch (DPI).-
336 \li setFullPage() tells QPrinter whether you want to deal with the-
337 full page or just with the part the printer can draw on.-
338 \li setCopyCount() tells QPrinter how many copies of the document-
339 it should print.-
340 \endlist-
341-
342 Many of these functions can only be called before the actual printing-
343 begins (i.e., before QPainter::begin() is called). This usually makes-
344 sense because, for example, it's not possible to change the number of-
345 copies when you are halfway through printing. There are also some-
346 settings that the user sets (through the printer dialog) and that-
347 applications are expected to obey. See QAbstractPrintDialog's-
348 documentation for more details.-
349-
350 When QPainter::begin() is called, the QPrinter it operates on is prepared for-
351 a new page, enabling the QPainter to be used immediately to paint the first-
352 page in a document. Once the first page has been painted, newPage() can be-
353 called to request a new blank page to paint on, or QPainter::end() can be-
354 called to finish printing. The second page and all following pages are-
355 prepared using a call to newPage() before they are painted.-
356-
357 The first page in a document does not need to be preceded by a call to-
358 newPage(). You only need to calling newPage() after QPainter::begin() if you-
359 need to insert a blank page at the beginning of a printed document.-
360 Similarly, calling newPage() after the last page in a document is painted will-
361 result in a trailing blank page appended to the end of the printed document.-
362-
363 If you want to abort the print job, abort() will try its best to-
364 stop printing. It may cancel the entire job or just part of it.-
365-
366 Since QPrinter can print to any QPrintEngine subclass, it is possible to-
367 extend printing support to cover new types of printing subsystem by-
368 subclassing QPrintEngine and reimplementing its interface.-
369-
370 \sa QPrintDialog, {Qt Print Support}-
371*/-
372-
373/*!-
374 \enum QPrinter::PrinterState-
375-
376 \value Idle-
377 \value Active-
378 \value Aborted-
379 \value Error-
380*/-
381-
382/*!-
383 \enum QPrinter::PrinterMode-
384-
385 This enum describes the mode the printer should work in. It-
386 basically presets a certain resolution and working mode.-
387-
388 \value ScreenResolution Sets the resolution of the print device to-
389 the screen resolution. This has the big advantage that the results-
390 obtained when painting on the printer will match more or less-
391 exactly the visible output on the screen. It is the easiest to-
392 use, as font metrics on the screen and on the printer are the-
393 same. This is the default value. ScreenResolution will produce a-
394 lower quality output than HighResolution and should only be used-
395 for drafts.-
396-
397 \value PrinterResolution This value is deprecated. It is-
398 equivalent to ScreenResolution on Unix and HighResolution on-
399 Windows and Mac. Due to the difference between ScreenResolution-
400 and HighResolution, use of this value may lead to non-portable-
401 printer code.-
402-
403 \value HighResolution On Windows, sets the printer resolution to that-
404 defined for the printer in use. For PDF printing, sets the-
405 resolution of the PDF driver to 1200 dpi.-
406-
407 \note When rendering text on a QPrinter device, it is important-
408 to realize that the size of text, when specified in points, is-
409 independent of the resolution specified for the device itself.-
410 Therefore, it may be useful to specify the font size in pixels-
411 when combining text with graphics to ensure that their relative-
412 sizes are what you expect.-
413*/-
414-
415/*!-
416 \enum QPrinter::Orientation-
417-
418 This enum type (not to be confused with \c Orientation) is used-
419 to specify each page's orientation.-
420-
421 \value Portrait the page's height is greater than its width.-
422-
423 \value Landscape the page's width is greater than its height.-
424-
425 This type interacts with \l QPrinter::PaperSize and-
426 QPrinter::setFullPage() to determine the final size of the page-
427 available to the application.-
428*/-
429-
430-
431/*!-
432 \enum QPrinter::PrintRange-
433-
434 Used to specify the print range selection option.-
435-
436 \value AllPages All pages should be printed.-
437 \value Selection Only the selection should be printed.-
438 \value PageRange The specified page range should be printed.-
439 \value CurrentPage Only the current page should be printed.-
440-
441 \sa setPrintRange(), printRange(), QAbstractPrintDialog::PrintRange-
442*/-
443-
444/*!-
445 \enum QPrinter::PaperSize-
446 \since 4.4-
447-
448 This enum type specifies what paper size QPrinter should use.-
449 QPrinter does not check that the paper size is available; it just-
450 uses this information, together with QPrinter::Orientation and-
451 QPrinter::setFullPage(), to determine the printable area.-
452-
453 The defined sizes (with setFullPage(true)) are:-
454-
455 \value A0 841 x 1189 mm-
456 \value A1 594 x 841 mm-
457 \value A2 420 x 594 mm-
458 \value A3 297 x 420 mm-
459 \value A4 210 x 297 mm, 8.26 x 11.69 inches-
460 \value A5 148 x 210 mm-
461 \value A6 105 x 148 mm-
462 \value A7 74 x 105 mm-
463 \value A8 52 x 74 mm-
464 \value A9 37 x 52 mm-
465 \value B0 1000 x 1414 mm-
466 \value B1 707 x 1000 mm-
467 \value B2 500 x 707 mm-
468 \value B3 353 x 500 mm-
469 \value B4 250 x 353 mm-
470 \value B5 176 x 250 mm, 6.93 x 9.84 inches-
471 \value B6 125 x 176 mm-
472 \value B7 88 x 125 mm-
473 \value B8 62 x 88 mm-
474 \value B9 33 x 62 mm-
475 \value B10 31 x 44 mm-
476 \value C5E 163 x 229 mm-
477 \value Comm10E 105 x 241 mm, U.S. Common 10 Envelope-
478 \value DLE 110 x 220 mm-
479 \value Executive 7.5 x 10 inches, 190.5 x 254 mm-
480 \value Folio 210 x 330 mm-
481 \value Ledger 431.8 x 279.4 mm-
482 \value Legal 8.5 x 14 inches, 215.9 x 355.6 mm-
483 \value Letter 8.5 x 11 inches, 215.9 x 279.4 mm-
484 \value Tabloid 279.4 x 431.8 mm-
485 \value Custom Unknown, or a user defined size.-
486 \value A10-
487 \value A3Extra-
488 \value A4Extra-
489 \value A4Plus-
490 \value A4Small-
491 \value A5Extra-
492 \value B5Extra-
493 \value JisB0-
494 \value JisB1-
495 \value JisB2-
496 \value JisB3-
497 \value JisB4-
498 \value JisB5-
499 \value JisB6,-
500 \value JisB7-
501 \value JisB8-
502 \value JisB9-
503 \value JisB10-
504 \value AnsiA = Letter-
505 \value AnsiB = Ledger-
506 \value AnsiC-
507 \value AnsiD-
508 \value AnsiE-
509 \value LegalExtra-
510 \value LetterExtra-
511 \value LetterPlus-
512 \value LetterSmall-
513 \value TabloidExtra-
514 \value ArchA-
515 \value ArchB-
516 \value ArchC-
517 \value ArchD-
518 \value ArchE-
519 \value Imperial7x9-
520 \value Imperial8x10-
521 \value Imperial9x11-
522 \value Imperial9x12-
523 \value Imperial10x11-
524 \value Imperial10x13-
525 \value Imperial10x14-
526 \value Imperial12x11-
527 \value Imperial15x11-
528 \value ExecutiveStandard-
529 \value Note-
530 \value Quarto-
531 \value Statement-
532 \value SuperA-
533 \value SuperB-
534 \value Postcard-
535 \value DoublePostcard-
536 \value Prc16K-
537 \value Prc32K-
538 \value Prc32KBig-
539 \value FanFoldUS-
540 \value FanFoldGerman-
541 \value FanFoldGermanLegal-
542 \value EnvelopeB4-
543 \value EnvelopeB5-
544 \value EnvelopeB6-
545 \value EnvelopeC0-
546 \value EnvelopeC1-
547 \value EnvelopeC2-
548 \value EnvelopeC3-
549 \value EnvelopeC4-
550 \value EnvelopeC5 = C5E-
551 \value EnvelopeC6-
552 \value EnvelopeC65-
553 \value EnvelopeC7-
554 \value EnvelopeDL = DLE-
555 \value Envelope9-
556 \value Envelope10 = Comm10E-
557 \value Envelope11-
558 \value Envelope12-
559 \value Envelope14-
560 \value EnvelopeMonarch-
561 \value EnvelopePersonal-
562 \value EnvelopeChou3-
563 \value EnvelopeChou4-
564 \value EnvelopeInvite-
565 \value EnvelopeItalian-
566 \value EnvelopeKaku2-
567 \value EnvelopeKaku3-
568 \value EnvelopePrc1-
569 \value EnvelopePrc2-
570 \value EnvelopePrc3-
571 \value EnvelopePrc4-
572 \value EnvelopePrc5-
573 \value EnvelopePrc6-
574 \value EnvelopePrc7-
575 \value EnvelopePrc8-
576 \value EnvelopePrc9-
577 \value EnvelopePrc10-
578 \value EnvelopeYou4-
579 \value LastPageSize = EnvelopeYou4-
580 \omitvalue NPageSize-
581 \omitvalue NPaperSize-
582-
583 With setFullPage(false) (the default), the metrics will be a bit-
584 smaller; how much depends on the printer in use.-
585-
586 Due to historic reasons QPageSize::Executive is not the same as the standard-
587 Postscript and Windows Executive size, use QPageSize::ExecutiveStandard instead.-
588-
589 The Postscript standard size QPageSize::Folio is different to the Windows-
590 DMPAPER_FOLIO size, use the Postscript standard size QPageSize::FanFoldGermanLegal-
591 if needed.-
592*/-
593-
594-
595/*!-
596 \enum QPrinter::PageOrder-
597-
598 This enum type is used by QPrinter to tell the application program-
599 how to print.-
600-
601 \value FirstPageFirst the lowest-numbered page should be printed-
602 first.-
603-
604 \value LastPageFirst the highest-numbered page should be printed-
605 first.-
606*/-
607-
608/*!-
609 \enum QPrinter::ColorMode-
610-
611 This enum type is used to indicate whether QPrinter should print-
612 in color or not.-
613-
614 \value Color print in color if available, otherwise in grayscale.-
615-
616 \value GrayScale print in grayscale, even on color printers.-
617*/-
618-
619/*!-
620 \enum QPrinter::PaperSource-
621-
622 This enum type specifies what paper source QPrinter is to use.-
623 QPrinter does not check that the paper source is available; it-
624 just uses this information to try and set the paper source.-
625 Whether it will set the paper source depends on whether the-
626 printer has that particular source.-
627-
628 \warning This is currently only implemented for Windows.-
629-
630 \value Auto-
631 \value Cassette-
632 \value Envelope-
633 \value EnvelopeManual-
634 \value FormSource-
635 \value LargeCapacity-
636 \value LargeFormat-
637 \value Lower-
638 \value MaxPageSource Deprecated, use LastPaperSource instead-
639 \value Middle-
640 \value Manual-
641 \value OnlyOne-
642 \value Tractor-
643 \value SmallFormat-
644 \value Upper-
645 \value CustomSource A PaperSource defined by the printer that is unknown to Qt-
646 \value LastPaperSource The highest valid PaperSource value, currently CustomSource-
647*/-
648-
649/*!-
650 \enum QPrinter::Unit-
651 \since 4.4-
652-
653 This enum type is used to specify the measurement unit for page and-
654 paper sizes.-
655-
656 \value Millimeter-
657 \value Point-
658 \value Inch-
659 \value Pica-
660 \value Didot-
661 \value Cicero-
662 \value DevicePixel-
663-
664 Note the difference between Point and DevicePixel. The Point unit is-
665 defined to be 1/72th of an inch, while the DevicePixel unit is-
666 resolution dependant and is based on the actual pixels, or dots, on-
667 the printer.-
668*/-
669-
670/*!-
671 Creates a new printer object with the given \a mode.-
672*/-
673QPrinter::QPrinter(PrinterMode mode)-
674 : QPagedPaintDevice(),-
675 d_ptr(new QPrinterPrivate(this))-
676{-
677 delete d;-
678 d = new QPrinterPagedPaintDevicePrivate(d_func());-
679 d_ptr->init(QPrinterInfo(), mode);-
680}
executed 128 times by 2 tests: end of block
Executed by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
128
681-
682/*!-
683 \since 4.4-
684-
685 Creates a new printer object with the given \a printer and \a mode.-
686*/-
687QPrinter::QPrinter(const QPrinterInfo& printer, PrinterMode mode)-
688 : QPagedPaintDevice(),-
689 d_ptr(new QPrinterPrivate(this))-
690{-
691 delete d;-
692 d = new QPrinterPagedPaintDevicePrivate(d_func());-
693 d_ptr->init(printer, mode);-
694}
never executed: end of block
0
695-
696void QPrinterPrivate::init(const QPrinterInfo &printer, QPrinter::PrinterMode mode)-
697{-
698 if (!QCoreApplication::instance()) {
!QCoreApplication::instance()Description
TRUEnever evaluated
FALSEevaluated 128 times by 2 tests
Evaluated by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
0-128
699 qFatal("QPrinter: Must construct a QCoreApplication before a QPrinter");-
700 return;
never executed: return;
0
701 }-
702-
703 printerMode = mode;-
704-
705 initEngines(QPrinter::NativeFormat, printer);-
706}
executed 128 times by 2 tests: end of block
Executed by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
128
707-
708/*!-
709 This function is used by subclasses of QPrinter to specify custom-
710 print and paint engines (\a printEngine and \a paintEngine,-
711 respectively).-
712-
713 QPrinter does not take ownership of the engines, so you need to-
714 manage these engine instances yourself.-
715-
716 Note that changing the engines will reset the printer state and-
717 all its properties.-
718-
719 \sa printEngine(), paintEngine(), setOutputFormat()-
720-
721 \since 4.1-
722*/-
723void QPrinter::setEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine)-
724{-
725 Q_D(QPrinter);-
726-
727 if (d->use_default_engine)
d->use_default_engineDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QPrinter
0-2
728 delete d->printEngine;
never executed: delete d->printEngine;
0
729-
730 d->printEngine = printEngine;-
731 d->paintEngine = paintEngine;-
732 d->use_default_engine = false;-
733}
executed 2 times by 1 test: end of block
Executed by:
  • tst_QPrinter
2
734-
735/*!-
736 Destroys the printer object and frees any allocated resources. If-
737 the printer is destroyed while a print job is in progress this may-
738 or may not affect the print job.-
739*/-
740QPrinter::~QPrinter()-
741{-
742 Q_D(QPrinter);-
743 if (d->use_default_engine)
d->use_default_engineDescription
TRUEevaluated 128 times by 2 tests
Evaluated by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
FALSEnever evaluated
0-128
744 delete d->printEngine;
executed 128 times by 2 tests: delete d->printEngine;
Executed by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
128
745#ifndef QT_NO_PRINTPREVIEWWIDGET-
746 delete d->previewEngine;-
747#endif-
748}
executed 128 times by 2 tests: end of block
Executed by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
128
749-
750/*!-
751 \enum QPrinter::OutputFormat-
752-
753 The OutputFormat enum is used to describe the format QPrinter should-
754 use for printing.-
755-
756 \value NativeFormat QPrinter will print output using a method defined-
757 by the platform it is running on. This mode is the default when printing-
758 directly to a printer.-
759-
760 \value PdfFormat QPrinter will generate its output as a searchable PDF file.-
761 This mode is the default when printing to a file.-
762-
763 \sa outputFormat(), setOutputFormat(), setOutputFileName()-
764*/-
765-
766/*!-
767 \since 4.1-
768-
769 Sets the output format for this printer to \a format.-
770-
771 If \a format is the same value as currently set then no change will be made.-
772-
773 If \a format is NativeFormat then the printerName will be set to the default-
774 printer. If there are no valid printers configured then no change will be made.-
775 If you want to set NativeFormat with a specific printerName then use-
776 setPrinterName().-
777-
778 \sa setPrinterName()-
779*/-
780void QPrinter::setOutputFormat(OutputFormat format)-
781{-
782 Q_D(QPrinter);-
783-
784 if (d->outputFormat == format)
d->outputFormat == formatDescription
TRUEevaluated 40 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QPrinter
6-40
785 return;
executed 40 times by 1 test: return;
Executed by:
  • tst_QPrinter
40
786-
787 if (format == QPrinter::NativeFormat) {
format == QPri...::NativeFormatDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-6
788 QPrinterInfo printerToUse = d->findValidPrinter();-
789 if (!printerToUse.isNull())
!printerToUse.isNull()Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QPrinter
0-6
790 d->changeEngines(format, printerToUse);
never executed: d->changeEngines(format, printerToUse);
0
791 } else {
executed 6 times by 1 test: end of block
Executed by:
  • tst_QPrinter
6
792 d->changeEngines(format, QPrinterInfo());-
793 }
never executed: end of block
0
794}-
795-
796/*!-
797 \since 4.1-
798-
799 Returns the output format for this printer.-
800*/-
801QPrinter::OutputFormat QPrinter::outputFormat() const-
802{-
803 Q_D(const QPrinter);-
804 return d->outputFormat;
executed 48 times by 1 test: return d->outputFormat;
Executed by:
  • tst_QPrinter
48
805}-
806-
807-
808-
809/*! \internal-
810*/-
811int QPrinter::devType() const-
812{-
813 return QInternal::Printer;
executed 108 times by 1 test: return QInternal::Printer;
Executed by:
  • tst_QPrinter
108
814}-
815-
816/*!-
817 Returns the printer name. This value is initially set to the name-
818 of the default printer.-
819-
820 \sa setPrinterName()-
821*/-
822QString QPrinter::printerName() const-
823{-
824 Q_D(const QPrinter);-
825 return d->printEngine->property(QPrintEngine::PPK_PrinterName).toString();
executed 15 times by 1 test: return d->printEngine->property(QPrintEngine::PPK_PrinterName).toString();
Executed by:
  • tst_QPrinter
15
826}-
827-
828/*!-
829 Sets the printer name to \a name.-
830-
831 If the \a name is empty then the output format will be set to PdfFormat.-
832-
833 If the \a name is not a valid printer then no change will be made.-
834-
835 If the \a name is a valid printer then the output format will be set to NativeFormat.-
836-
837 \sa printerName(), isValid(), setOutputFormat()-
838*/-
839void QPrinter::setPrinterName(const QString &name)-
840{-
841 Q_D(QPrinter);-
842 ABORT_IF_ACTIVE("QPrinter::setPrinterName");
never executed: return;
d->printEngine...rinter::ActiveDescription
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QPrinter
0-5
843-
844 if (printerName() == name)
printerName() == nameDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
1-4
845 return;
executed 4 times by 1 test: return;
Executed by:
  • tst_QPrinter
4
846-
847 if (name.isEmpty()) {
name.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
0-1
848 setOutputFormat(QPrinter::PdfFormat);-
849 return;
never executed: return;
0
850 }-
851-
852 QPrinterInfo printerToUse = QPrinterInfo::printerInfo(name);-
853 if (printerToUse.isNull())
printerToUse.isNull()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-1
854 return;
executed 1 time by 1 test: return;
Executed by:
  • tst_QPrinter
1
855-
856 if (outputFormat() == QPrinter::PdfFormat) {
outputFormat()...ter::PdfFormatDescription
TRUEnever evaluated
FALSEnever evaluated
0
857 d->changeEngines(QPrinter::NativeFormat, printerToUse);-
858 } else {
never executed: end of block
0
859 d->setProperty(QPrintEngine::PPK_PrinterName, name);-
860 }
never executed: end of block
0
861}-
862-
863/*!-
864 \since 4.4-
865-
866 Returns \c true if the printer currently selected is a valid printer-
867 in the system, or a pure PDF printer; otherwise returns \c false.-
868-
869 To detect other failures check the output of QPainter::begin() or QPrinter::newPage().-
870-
871 \snippet printing-qprinter/errors.cpp 0-
872-
873 \sa setPrinterName()-
874*/-
875bool QPrinter::isValid() const-
876{-
877 Q_D(const QPrinter);-
878 if (!qApp)
!QCoreApplication::instance()Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QPrinter
0-3
879 return false;
never executed: return false;
0
880 return d->validPrinter;
executed 3 times by 1 test: return d->validPrinter;
Executed by:
  • tst_QPrinter
3
881}-
882-
883/*!-
884 \fn QString QPrinter::outputFileName() const-
885-
886 Returns the name of the output file. By default, this is an empty string-
887 (indicating that the printer shouldn't print to file).-
888-
889 \sa QPrintEngine::PrintEnginePropertyKey-
890-
891*/-
892-
893QString QPrinter::outputFileName() const-
894{-
895 Q_D(const QPrinter);-
896 return d->printEngine->property(QPrintEngine::PPK_OutputFileName).toString();
executed 5 times by 1 test: return d->printEngine->property(QPrintEngine::PPK_OutputFileName).toString();
Executed by:
  • tst_QPrinter
5
897}-
898-
899/*!-
900 Sets the name of the output file to \a fileName.-
901-
902 Setting a null or empty name (0 or "") disables printing to a file.-
903 Setting a non-empty name enables printing to a file.-
904-
905 This can change the value of outputFormat().-
906 If the file name has the ".pdf" suffix PDF is generated. If the file name-
907 has a suffix other than ".pdf", the output format used is the-
908 one set with setOutputFormat().-
909-
910 QPrinter uses Qt's cross-platform PDF print engines-
911 respectively. If you can produce this format natively, for example-
912 \macos can generate PDF's from its print engine, set the output format-
913 back to NativeFormat.-
914-
915 \sa outputFileName(), setOutputFormat()-
916*/-
917-
918void QPrinter::setOutputFileName(const QString &fileName)-
919{-
920 Q_D(QPrinter);-
921 ABORT_IF_ACTIVE("QPrinter::setOutputFileName");
never executed: return;
d->printEngine...rinter::ActiveDescription
TRUEnever evaluated
FALSEevaluated 39 times by 1 test
Evaluated by:
  • tst_QPrinter
0-39
922-
923 QFileInfo fi(fileName);-
924 if (!fi.suffix().compare(QLatin1String("pdf"), Qt::CaseInsensitive))
!fi.suffix().c...seInsensitive)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEevaluated 33 times by 1 test
Evaluated by:
  • tst_QPrinter
6-33
925 setOutputFormat(QPrinter::PdfFormat);
executed 6 times by 1 test: setOutputFormat(QPrinter::PdfFormat);
Executed by:
  • tst_QPrinter
6
926 else if (fileName.isEmpty())
fileName.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 33 times by 1 test
Evaluated by:
  • tst_QPrinter
0-33
927 setOutputFormat(QPrinter::NativeFormat);
never executed: setOutputFormat(QPrinter::NativeFormat);
0
928-
929 d->setProperty(QPrintEngine::PPK_OutputFileName, fileName);-
930}
executed 39 times by 1 test: end of block
Executed by:
  • tst_QPrinter
39
931-
932-
933/*!-
934 Returns the name of the program that sends the print output to the-
935 printer.-
936-
937 The default is to return an empty string; meaning that QPrinter will try to-
938 be smart in a system-dependent way. On X11 only, you can set it to something-
939 different to use a specific print program. On the other platforms, this-
940 returns an empty string.-
941-
942 \sa setPrintProgram(), setPrinterSelectionOption()-
943*/-
944QString QPrinter::printProgram() const-
945{-
946 Q_D(const QPrinter);-
947 return d->printEngine->property(QPrintEngine::PPK_PrinterProgram).toString();
executed 2 times by 1 test: return d->printEngine->property(QPrintEngine::PPK_PrinterProgram).toString();
Executed by:
  • tst_QPrinter
2
948}-
949-
950-
951/*!-
952 Sets the name of the program that should do the print job to \a-
953 printProg.-
954-
955 On X11, this function sets the program to call with the PDF-
956 output. On other platforms, it has no effect.-
957-
958 \sa printProgram()-
959*/-
960void QPrinter::setPrintProgram(const QString &printProg)-
961{-
962 Q_D(QPrinter);-
963 ABORT_IF_ACTIVE("QPrinter::setPrintProgram");
never executed: return;
d->printEngine...rinter::ActiveDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
0-1
964 d->setProperty(QPrintEngine::PPK_PrinterProgram, printProg);-
965}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
966-
967-
968/*!-
969 Returns the document name.-
970-
971 \sa setDocName(), QPrintEngine::PrintEnginePropertyKey-
972*/-
973QString QPrinter::docName() const-
974{-
975 Q_D(const QPrinter);-
976 return d->printEngine->property(QPrintEngine::PPK_DocumentName).toString();
executed 6 times by 1 test: return d->printEngine->property(QPrintEngine::PPK_DocumentName).toString();
Executed by:
  • tst_QPrinter
6
977}-
978-
979-
980/*!-
981 Sets the document name to \a name.-
982-
983 On X11, the document name is for example used as the default-
984 output filename in QPrintDialog. Note that the document name does-
985 not affect the file name if the printer is printing to a file.-
986 Use the setOutputFile() function for this.-
987-
988 \sa docName(), QPrintEngine::PrintEnginePropertyKey-
989*/-
990void QPrinter::setDocName(const QString &name)-
991{-
992 Q_D(QPrinter);-
993 ABORT_IF_ACTIVE("QPrinter::setDocName");
never executed: return;
d->printEngine...rinter::ActiveDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QPrinter
0-2
994 d->setProperty(QPrintEngine::PPK_DocumentName, name);-
995}
executed 2 times by 1 test: end of block
Executed by:
  • tst_QPrinter
2
996-
997-
998/*!-
999 Returns the name of the application that created the document.-
1000-
1001 \sa setCreator()-
1002*/-
1003QString QPrinter::creator() const-
1004{-
1005 Q_D(const QPrinter);-
1006 return d->printEngine->property(QPrintEngine::PPK_Creator).toString();
executed 2 times by 1 test: return d->printEngine->property(QPrintEngine::PPK_Creator).toString();
Executed by:
  • tst_QPrinter
2
1007}-
1008-
1009-
1010/*!-
1011 Sets the name of the application that created the document to \a-
1012 creator.-
1013-
1014 This function is only applicable to the X11 version of Qt. If no-
1015 creator name is specified, the creator will be set to "Qt"-
1016 followed by some version number.-
1017-
1018 \sa creator()-
1019*/-
1020void QPrinter::setCreator(const QString &creator)-
1021{-
1022 Q_D(QPrinter);-
1023 ABORT_IF_ACTIVE("QPrinter::setCreator");
never executed: return;
d->printEngine...rinter::ActiveDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
0-1
1024 d->setProperty(QPrintEngine::PPK_Creator, creator);-
1025}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
1026-
1027// Defined in QPagedPaintDevice but non-virtual, add QPrinter specific doc here-
1028#ifdef Q_QDOC-
1029/*!-
1030 \fn bool QPrinter::setPageLayout(const QPageLayout &newLayout)-
1031 \since 5.3-
1032-
1033 Sets the page layout to \a newLayout.-
1034-
1035 If the \a newLayout is not valid for the current printer then the page-
1036 layout will not be changed. For example, if the page size is not supported-
1037 by the printer, or if the margins fall outside the printable area.-
1038-
1039 Returns true if the page layout was successfully set to \a newLayout.-
1040-
1041 \sa pageLayout(), setPageSize(), setPageOrientation(), setPageMargins()-
1042*/-
1043-
1044/*!-
1045 \fn bool QPrinter::setPageSize(const QPageSize &pageSize)-
1046 \since 5.3-
1047-
1048 Sets the page size to \a pageSize.-
1049-
1050 If the \a pageSize is not valid for the current printer then the page-
1051 size will not be changed.-
1052-
1053 Changing the page size may affect the current page margins if they fall-
1054 outside the printable margins for the new page size on the current printer.-
1055-
1056 To obtain the current QPageSize use pageLayout().pageSize().-
1057-
1058 Returns true if the page size was successfully set to \a pageSize.-
1059-
1060 \sa pageLayout(), setPageLayout()-
1061*/-
1062-
1063/*!-
1064 \fn bool QPrinter::setPageOrientation(QPageLayout::Orientation orientation)-
1065 \since 5.3-
1066-
1067 Sets the page \a orientation to QPageLayout::Portrait or QPageLayout::Landscape.-
1068-
1069 The printer driver reads this setting and prints the page using the-
1070 specified orientation.-
1071-
1072 On Windows and Mac, this option can be changed while printing and will-
1073 take effect from the next call to newPage().-
1074-
1075 To obtain the current QPageLayout::Orientation use pageLayout().pageOrientation().-
1076-
1077 Returns true if the page orientation was successfully set to \a orientation.-
1078-
1079 \sa pageLayout(), setPageLayout()-
1080*/-
1081-
1082/*!-
1083 \fn bool QPrinter::setPageMargins(const QMarginsF &margins, QPageLayout::Unit units)-
1084 \since 5.3-
1085-
1086 Set the page margins to \a margins in the given \a units. If \a units are-
1087 not provided then the current units are used.-
1088-
1089 If in Full Page mode then no check is performed on the \a margins set,-
1090 otherwise the \a margins must fall within the printable area for the page-
1091 size on the current printer.-
1092-
1093 To obtain the current page margins use pageLayout().pageMargins().-
1094-
1095 Returns \c true if the page margins was successfully set to \a margins.-
1096-
1097 \sa pageLayout(), setPageLayout()-
1098*/-
1099-
1100/*!-
1101 \fn bool QPrinter::setPageMargins(const QMarginsF &margins)-
1102-
1103 Set the page margins to \a margins using the current units.-
1104 Returns \c true if the page margins were set successfully.-
1105-
1106 \sa pageLayout(), setPageLayout()-
1107*/-
1108/*!-
1109 \fn QPageLayout QPrinter::pageLayout() const-
1110 \since 5.3-
1111-
1112 Returns the current page layout. Use this method to access the current-
1113 QPageSize, QPageLayout::Orientation, QMarginsF, fullPageRect() and paintRect().-
1114-
1115 Note that you cannot use the setters on the returned object, you must either-
1116 call the QPrinter methods or setPageLayout().-
1117-
1118 \sa setPageLayout(), setPageSize(), setPageOrientation(), setPageMargins()-
1119*/-
1120#endif-
1121-
1122/*!-
1123 \obsolete Use pageLayout().pageOrientation() instead.-
1124-
1125 Returns the orientation setting. This is driver-dependent, but is usually-
1126 QPrinter::Portrait.-
1127-
1128 \sa pageLayout()-
1129*/-
1130QPrinter::Orientation QPrinter::orientation() const-
1131{-
1132 return QPrinter::Orientation(pageLayout().orientation());
executed 75 times by 1 test: return QPrinter::Orientation(pageLayout().orientation());
Executed by:
  • tst_QPrinter
75
1133}-
1134-
1135-
1136/*!-
1137 \obsolete Use setPageOrientation() instead.-
1138-
1139 Sets the print orientation to \a orientation.-
1140-
1141 The orientation can be either QPrinter::Portrait or-
1142 QPrinter::Landscape.-
1143-
1144 The printer driver reads this setting and prints using the-
1145 specified orientation.-
1146-
1147 On Windows and Mac, this option can be changed while printing and will-
1148 take effect from the next call to newPage().-
1149-
1150 \sa setPageOrientation()-
1151*/-
1152-
1153void QPrinter::setOrientation(Orientation orientation)-
1154{-
1155 setPageOrientation(QPageLayout::Orientation(orientation));-
1156}
executed 48 times by 1 test: end of block
Executed by:
  • tst_QPrinter
48
1157-
1158/*!-
1159 \since 4.4-
1160-
1161 \obsolete Use pageLayout().pageSize().id() instead.-
1162-
1163 Returns the printer paper size. The default value is driver-dependent.-
1164-
1165 \sa pageLayout()-
1166*/-
1167-
1168QPrinter::PaperSize QPrinter::paperSize() const-
1169{-
1170 return pageSize();
executed 2 times by 1 test: return pageSize();
Executed by:
  • tst_QPrinter
2
1171}-
1172-
1173/*!-
1174 \since 4.4-
1175-
1176 \obsolete Use setPageSize(QPageSize) instead.-
1177-
1178 Sets the printer paper size to \a newPaperSize if that size is-
1179 supported. The result is undefined if \a newPaperSize is not-
1180 supported.-
1181-
1182 The default paper size is driver-dependent.-
1183-
1184 This function is useful mostly for setting a default value that-
1185 the user can override in the print dialog.-
1186-
1187 \sa setPageSize()-
1188*/-
1189void QPrinter::setPaperSize(PaperSize newPaperSize)-
1190{-
1191 setPageSize(QPageSize(QPageSize::PageSizeId(newPaperSize)));-
1192}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
1193-
1194/*!-
1195 \obsolete Use pageLayout().pageSize().id() instead.-
1196-
1197 Returns the printer page size. The default value is driver-dependent.-
1198-
1199 \sa pageLayout()-
1200*/-
1201QPrinter::PageSize QPrinter::pageSize() const-
1202{-
1203 return QPrinter::PaperSize(pageLayout().pageSize().id());
executed 31 times by 1 test: return QPrinter::PaperSize(pageLayout().pageSize().id());
Executed by:
  • tst_QPrinter
31
1204}-
1205-
1206-
1207/*!-
1208 \obsolete Use setPageSize(QPageSize) instead.-
1209-
1210 Sets the printer page size based on \a newPageSize.-
1211-
1212 \sa setPageSize()-
1213*/-
1214-
1215void QPrinter::setPageSize(PageSize newPageSize)-
1216{-
1217 setPageSize(QPageSize(QPageSize::PageSizeId(newPageSize)));-
1218}
executed 31 times by 1 test: end of block
Executed by:
  • tst_QPrinter
31
1219-
1220/*!-
1221 \since 4.4-
1222-
1223 \obsolete Use setPageSize(QPageSize) instead.-
1224-
1225 Sets the paper size based on \a paperSize in \a unit.-
1226-
1227 Note that the paper size is defined in a portrait layout, regardless of-
1228 what the current printer orientation is set to.-
1229-
1230 \sa setPageSize()-
1231*/-
1232-
1233void QPrinter::setPaperSize(const QSizeF &paperSize, QPrinter::Unit unit)-
1234{-
1235 if (unit == QPrinter::DevicePixel)
unit == QPrinter::DevicePixelDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QPrinter
1-6
1236 setPageSize(QPageSize(paperSize * qt_pixelMultiplier(resolution()), QPageSize::Point));
executed 1 time by 1 test: setPageSize(QPageSize(paperSize * qt_pixelMultiplier(resolution()), QPageSize::Point));
Executed by:
  • tst_QPrinter
1
1237 else-
1238 setPageSize(QPageSize(paperSize, QPageSize::Unit(unit)));
executed 6 times by 1 test: setPageSize(QPageSize(paperSize, QPageSize::Unit(unit)));
Executed by:
  • tst_QPrinter
6
1239}-
1240-
1241/*!-
1242 \reimp-
1243-
1244 \obsolete Use setPageSize(QPageSize) instead.-
1245-
1246 Use setPageSize(QPageSize) instead.-
1247-
1248 Note that the page size is defined in a portrait layout, regardless of-
1249 what the current printer orientation is set to.-
1250-
1251 \sa setPageSize()-
1252*/-
1253void QPrinter::setPageSizeMM(const QSizeF &size)-
1254{-
1255 setPageSize(QPageSize(size, QPageSize::Millimeter));-
1256}
executed 8 times by 1 test: end of block
Executed by:
  • tst_QPrinter
8
1257-
1258/*!-
1259 \since 4.4-
1260-
1261 \obsolete Use pageLayout().pageSize().size() or-
1262 pageLayout().fullPageSize() instead.-
1263-
1264 Returns the paper size in \a unit.-
1265-
1266 Note that the returned size reflects the current paper orientation.-
1267-
1268 \sa pageLayout()-
1269*/-
1270-
1271QSizeF QPrinter::paperSize(Unit unit) const-
1272{-
1273 if (unit == QPrinter::DevicePixel)
unit == QPrinter::DevicePixelDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
FALSEevaluated 21 times by 1 test
Evaluated by:
  • tst_QPrinter
1-21
1274 return pageLayout().fullRectPixels(resolution()).size();
executed 1 time by 1 test: return pageLayout().fullRectPixels(resolution()).size();
Executed by:
  • tst_QPrinter
1
1275 else-
1276 return pageLayout().fullRect(QPageLayout::Unit(unit)).size();
executed 21 times by 1 test: return pageLayout().fullRect(QPageLayout::Unit(unit)).size();
Executed by:
  • tst_QPrinter
21
1277}-
1278-
1279/*!-
1280 \since 5.1-
1281-
1282 \obsolete Use setPageSize(QPageSize) instead.-
1283-
1284 Sets the paper used by the printer to \a paperName.-
1285-
1286 \sa setPageSize()-
1287*/-
1288-
1289void QPrinter::setPaperName(const QString &paperName)-
1290{-
1291 Q_D(QPrinter);-
1292 if (d->paintEngine->type() != QPaintEngine::Pdf)
d->paintEngine...intEngine::PdfDescription
TRUEnever evaluated
FALSEnever evaluated
0
1293 ABORT_IF_ACTIVE("QPrinter::setPaperName");
never executed: return;
d->printEngine...rinter::ActiveDescription
TRUEnever evaluated
FALSEnever evaluated
0
1294 d->setProperty(QPrintEngine::PPK_PaperName, paperName);-
1295}
never executed: end of block
0
1296-
1297/*!-
1298 \since 5.1-
1299-
1300 \obsolete Use pageLayout().pageSize().name() instead.-
1301-
1302 Returns the paper name of the paper set on the printer.-
1303-
1304 The default value for this is driver-dependent.-
1305-
1306 \sa pageLayout()-
1307*/-
1308-
1309QString QPrinter::paperName() const-
1310{-
1311 Q_D(const QPrinter);-
1312 return d->printEngine->property(QPrintEngine::PPK_PaperName).toString();
never executed: return d->printEngine->property(QPrintEngine::PPK_PaperName).toString();
0
1313}-
1314-
1315/*!-
1316 Sets the page order to \a pageOrder.-
1317-
1318 The page order can be QPrinter::FirstPageFirst or-
1319 QPrinter::LastPageFirst. The application is responsible for-
1320 reading the page order and printing accordingly.-
1321-
1322 This function is mostly useful for setting a default value that-
1323 the user can override in the print dialog.-
1324-
1325 This function is only supported under X11.-
1326*/-
1327-
1328void QPrinter::setPageOrder(PageOrder pageOrder)-
1329{-
1330 d->pageOrderAscending = (pageOrder == FirstPageFirst);-
1331-
1332 Q_D(QPrinter);-
1333 ABORT_IF_ACTIVE("QPrinter::setPageOrder");
never executed: return;
d->printEngine...rinter::ActiveDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
0-1
1334 d->setProperty(QPrintEngine::PPK_PageOrder, pageOrder);-
1335}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
1336-
1337-
1338/*!-
1339 Returns the current page order.-
1340-
1341 The default page order is \c FirstPageFirst.-
1342*/-
1343-
1344QPrinter::PageOrder QPrinter::pageOrder() const-
1345{-
1346 Q_D(const QPrinter);-
1347 return QPrinter::PageOrder(d->printEngine->property(QPrintEngine::PPK_PageOrder).toInt());
executed 6 times by 1 test: return QPrinter::PageOrder(d->printEngine->property(QPrintEngine::PPK_PageOrder).toInt());
Executed by:
  • tst_QPrinter
6
1348}-
1349-
1350-
1351/*!-
1352 Sets the printer's color mode to \a newColorMode, which can be-
1353 either \c Color or \c GrayScale.-
1354-
1355 \sa colorMode()-
1356*/-
1357-
1358void QPrinter::setColorMode(ColorMode newColorMode)-
1359{-
1360 Q_D(QPrinter);-
1361 ABORT_IF_ACTIVE("QPrinter::setColorMode");
never executed: return;
d->printEngine...rinter::ActiveDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
0-1
1362 d->setProperty(QPrintEngine::PPK_ColorMode, newColorMode);-
1363}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
1364-
1365-
1366/*!-
1367 Returns the current color mode.-
1368-
1369 \sa setColorMode()-
1370*/-
1371QPrinter::ColorMode QPrinter::colorMode() const-
1372{-
1373 Q_D(const QPrinter);-
1374 return QPrinter::ColorMode(d->printEngine->property(QPrintEngine::PPK_ColorMode).toInt());
executed 6 times by 1 test: return QPrinter::ColorMode(d->printEngine->property(QPrintEngine::PPK_ColorMode).toInt());
Executed by:
  • tst_QPrinter
6
1375}-
1376-
1377-
1378/*!-
1379 \obsolete-
1380 Returns the number of copies to be printed. The default value is 1.-
1381-
1382 On Windows, \macos and X11 systems that support CUPS, this will always-
1383 return 1 as these operating systems can internally handle the number-
1384 of copies.-
1385-
1386 On X11, this value will return the number of times the application is-
1387 required to print in order to match the number specified in the printer setup-
1388 dialog. This has been done since some printer drivers are not capable of-
1389 buffering up the copies and in those cases the application must make an-
1390 explicit call to the print code for each copy.-
1391-
1392 Use copyCount() in conjunction with supportsMultipleCopies() instead.-
1393-
1394 \sa setNumCopies(), actualNumCopies()-
1395*/-
1396-
1397int QPrinter::numCopies() const-
1398{-
1399 Q_D(const QPrinter);-
1400 return d->printEngine->property(QPrintEngine::PPK_NumberOfCopies).toInt();
executed 3 times by 1 test: return d->printEngine->property(QPrintEngine::PPK_NumberOfCopies).toInt();
Executed by:
  • tst_QPrinter
3
1401}-
1402-
1403-
1404/*!-
1405 \obsolete-
1406 \since 4.6-
1407-
1408 Returns the number of copies that will be printed. The default-
1409 value is 1.-
1410-
1411 This function always returns the actual value specified in the print-
1412 dialog or using setNumCopies().-
1413-
1414 Use copyCount() instead.-
1415-
1416 \sa setNumCopies(), numCopies()-
1417*/-
1418int QPrinter::actualNumCopies() const-
1419{-
1420 return copyCount();
executed 3 times by 1 test: return copyCount();
Executed by:
  • tst_QPrinter
3
1421}-
1422-
1423-
1424-
1425/*!-
1426 \obsolete-
1427 Sets the number of copies to be printed to \a numCopies.-
1428-
1429 The printer driver reads this setting and prints the specified-
1430 number of copies.-
1431-
1432 Use setCopyCount() instead.-
1433-
1434 \sa numCopies()-
1435*/-
1436-
1437void QPrinter::setNumCopies(int numCopies)-
1438{-
1439 Q_D(QPrinter);-
1440 ABORT_IF_ACTIVE("QPrinter::setNumCopies");
never executed: return;
d->printEngine...rinter::ActiveDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
0-1
1441 d->setProperty(QPrintEngine::PPK_NumberOfCopies, numCopies);-
1442}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
1443-
1444/*!-
1445 \since 4.7-
1446-
1447 Sets the number of copies to be printed to \a count.-
1448-
1449 The printer driver reads this setting and prints the specified number of-
1450 copies.-
1451-
1452 \sa copyCount(), supportsMultipleCopies()-
1453*/-
1454-
1455void QPrinter::setCopyCount(int count)-
1456{-
1457 Q_D(QPrinter);-
1458 ABORT_IF_ACTIVE("QPrinter::setCopyCount;");
never executed: return;
d->printEngine...rinter::ActiveDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
0-1
1459 d->setProperty(QPrintEngine::PPK_CopyCount, count);-
1460}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
1461-
1462/*!-
1463 \since 4.7-
1464-
1465 Returns the number of copies that will be printed. The default value is 1.-
1466-
1467 \sa setCopyCount(), supportsMultipleCopies()-
1468*/-
1469-
1470int QPrinter::copyCount() const-
1471{-
1472 Q_D(const QPrinter);-
1473 return d->printEngine->property(QPrintEngine::PPK_CopyCount).toInt();
executed 10 times by 1 test: return d->printEngine->property(QPrintEngine::PPK_CopyCount).toInt();
Executed by:
  • tst_QPrinter
10
1474}-
1475-
1476/*!-
1477 \since 4.7-
1478-
1479 Returns \c true if the printer supports printing multiple copies of the same-
1480 document in one job; otherwise false is returned.-
1481-
1482 On most systems this function will return true. However, on X11 systems-
1483 that do not support CUPS, this function will return false. That means the-
1484 application has to handle the number of copies by printing the same-
1485 document the required number of times.-
1486-
1487 \sa setCopyCount(), copyCount()-
1488*/-
1489-
1490bool QPrinter::supportsMultipleCopies() const-
1491{-
1492 Q_D(const QPrinter);-
1493 return d->printEngine->property(QPrintEngine::PPK_SupportsMultipleCopies).toBool();
executed 1 time by 1 test: return d->printEngine->property(QPrintEngine::PPK_SupportsMultipleCopies).toBool();
Executed by:
  • tst_QPrinter
1
1494}-
1495-
1496/*!-
1497 \since 4.1-
1498-
1499 Returns \c true if collation is turned on when multiple copies is selected.-
1500 Returns \c false if it is turned off when multiple copies is selected.-
1501 When collating is turned off the printing of each individual page will be repeated-
1502 the numCopies() amount before the next page is started. With collating turned on-
1503 all pages are printed before the next copy of those pages is started.-
1504-
1505 \sa setCollateCopies()-
1506*/-
1507bool QPrinter::collateCopies() const-
1508{-
1509 Q_D(const QPrinter);-
1510 return d->printEngine->property(QPrintEngine::PPK_CollateCopies).toBool();
executed 6 times by 1 test: return d->printEngine->property(QPrintEngine::PPK_CollateCopies).toBool();
Executed by:
  • tst_QPrinter
6
1511}-
1512-
1513-
1514/*!-
1515 \since 4.1-
1516-
1517 Sets the default value for collation checkbox when the print-
1518 dialog appears. If \a collate is true, it will enable-
1519 setCollateCopiesEnabled(). The default value is false. This value-
1520 will be changed by what the user presses in the print dialog.-
1521-
1522 \sa collateCopies()-
1523*/-
1524void QPrinter::setCollateCopies(bool collate)-
1525{-
1526 Q_D(QPrinter);-
1527 ABORT_IF_ACTIVE("QPrinter::setCollateCopies");
never executed: return;
d->printEngine...rinter::ActiveDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
0-1
1528 d->setProperty(QPrintEngine::PPK_CollateCopies, collate);-
1529}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
1530-
1531-
1532-
1533/*!-
1534 If \a fp is true, enables support for painting over the entire page;-
1535 otherwise restricts painting to the printable area reported by the-
1536 device.-
1537-
1538 By default, full page printing is disabled. In this case, the origin-
1539 of the QPrinter's coordinate system coincides with the top-left-
1540 corner of the printable area.-
1541-
1542 If full page printing is enabled, the origin of the QPrinter's-
1543 coordinate system coincides with the top-left corner of the paper-
1544 itself. In this case, the-
1545 \l{QPaintDevice::PaintDeviceMetric}{device metrics} will report-
1546 the exact same dimensions as indicated by \l{PaperSize}. It may not-
1547 be possible to print on the entire physical page because of the-
1548 printer's margins, so the application must account for the margins-
1549 itself.-
1550-
1551 \sa fullPage(), pageLayout(), setPageSize(), width(), height()-
1552*/-
1553-
1554void QPrinter::setFullPage(bool fp)-
1555{-
1556 Q_D(QPrinter);-
1557 // Set the print engine-
1558 d->setProperty(QPrintEngine::PPK_FullPage, fp);-
1559 // Set QPagedPaintDevice layout to match the current print engine value-
1560 devicePageLayout() = pageLayout();-
1561}
executed 19 times by 1 test: end of block
Executed by:
  • tst_QPrinter
19
1562-
1563-
1564/*!-
1565 Returns \c true if the origin of the printer's coordinate system is-
1566 at the corner of the page and false if it is at the edge of the-
1567 printable area.-
1568-
1569 See setFullPage() for details and caveats.-
1570-
1571 \sa setFullPage(), pageLayout()-
1572*/-
1573-
1574bool QPrinter::fullPage() const-
1575{-
1576 Q_D(const QPrinter);-
1577 return d->printEngine->property(QPrintEngine::PPK_FullPage).toBool();
executed 3 times by 1 test: return d->printEngine->property(QPrintEngine::PPK_FullPage).toBool();
Executed by:
  • tst_QPrinter
3
1578}-
1579-
1580-
1581/*!-
1582 Requests that the printer prints at \a dpi or as near to \a dpi as-
1583 possible.-
1584-
1585 This setting affects the coordinate system as returned by, for-
1586 example QPainter::viewport().-
1587-
1588 This function must be called before QPainter::begin() to have an effect on-
1589 all platforms.-
1590-
1591 \sa resolution(), setPaperSize()-
1592*/-
1593-
1594void QPrinter::setResolution(int dpi)-
1595{-
1596 Q_D(QPrinter);-
1597 ABORT_IF_ACTIVE("QPrinter::setResolution");
never executed: return;
d->printEngine...rinter::ActiveDescription
TRUEnever evaluated
FALSEevaluated 27 times by 1 test
Evaluated by:
  • tst_QPrinter
0-27
1598 d->setProperty(QPrintEngine::PPK_Resolution, dpi);-
1599}
executed 27 times by 1 test: end of block
Executed by:
  • tst_QPrinter
27
1600-
1601-
1602/*!-
1603 Returns the current assumed resolution of the printer, as set by-
1604 setResolution() or by the printer driver.-
1605-
1606 \sa setResolution()-
1607*/-
1608-
1609int QPrinter::resolution() const-
1610{-
1611 Q_D(const QPrinter);-
1612 return d->printEngine->property(QPrintEngine::PPK_Resolution).toInt();
executed 110 times by 1 test: return d->printEngine->property(QPrintEngine::PPK_Resolution).toInt();
Executed by:
  • tst_QPrinter
110
1613}-
1614-
1615/*!-
1616 Sets the paper source setting to \a source.-
1617-
1618 Windows only: This option can be changed while printing and will-
1619 take effect from the next call to newPage()-
1620-
1621 \sa paperSource()-
1622*/-
1623-
1624void QPrinter::setPaperSource(PaperSource source)-
1625{-
1626 Q_D(QPrinter);-
1627 d->setProperty(QPrintEngine::PPK_PaperSource, source);-
1628}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
1629-
1630/*!-
1631 Returns the printer's paper source. This is \c Manual or a printer-
1632 tray or paper cassette.-
1633*/-
1634QPrinter::PaperSource QPrinter::paperSource() const-
1635{-
1636 Q_D(const QPrinter);-
1637 return QPrinter::PaperSource(d->printEngine->property(QPrintEngine::PPK_PaperSource).toInt());
executed 2 times by 1 test: return QPrinter::PaperSource(d->printEngine->property(QPrintEngine::PPK_PaperSource).toInt());
Executed by:
  • tst_QPrinter
2
1638}-
1639-
1640-
1641/*!-
1642 \since 4.1-
1643-
1644 Enabled or disables font embedding depending on \a enable.-
1645-
1646 \sa fontEmbeddingEnabled()-
1647*/-
1648void QPrinter::setFontEmbeddingEnabled(bool enable)-
1649{-
1650 Q_D(QPrinter);-
1651 d->setProperty(QPrintEngine::PPK_FontEmbedding, enable);-
1652}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
1653-
1654/*!-
1655 \since 4.1-
1656-
1657 Returns \c true if font embedding is enabled.-
1658-
1659 \sa setFontEmbeddingEnabled()-
1660*/-
1661bool QPrinter::fontEmbeddingEnabled() const-
1662{-
1663 Q_D(const QPrinter);-
1664 return d->printEngine->property(QPrintEngine::PPK_FontEmbedding).toBool();
executed 2 times by 1 test: return d->printEngine->property(QPrintEngine::PPK_FontEmbedding).toBool();
Executed by:
  • tst_QPrinter
2
1665}-
1666-
1667/*!-
1668 \enum QPrinter::DuplexMode-
1669 \since 4.4-
1670-
1671 This enum is used to indicate whether printing will occur on one or both sides-
1672 of each sheet of paper (simplex or duplex printing).-
1673-
1674 \value DuplexNone Single sided (simplex) printing only.-
1675 \value DuplexAuto The printer's default setting is used to determine whether-
1676 duplex printing is used.-
1677 \value DuplexLongSide Both sides of each sheet of paper are used for printing.-
1678 The paper is turned over its longest edge before the second-
1679 side is printed-
1680 \value DuplexShortSide Both sides of each sheet of paper are used for printing.-
1681 The paper is turned over its shortest edge before the second-
1682 side is printed-
1683*/-
1684-
1685/*!-
1686 \since 4.2-
1687-
1688 \obsolete Use setDuplex() instead.-
1689-
1690 Enables double sided printing if \a doubleSided is true; otherwise disables it.-
1691-
1692 \sa setDuplex()-
1693*/-
1694void QPrinter::setDoubleSidedPrinting(bool doubleSided)-
1695{-
1696 setDuplex(doubleSided ? DuplexAuto : DuplexNone);-
1697}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
1698-
1699-
1700/*!-
1701 \since 4.2-
1702-
1703 \obsolete Use duplex() instead.-
1704-
1705 Returns \c true if double side printing is enabled.-
1706-
1707 \sa duplex()-
1708*/-
1709bool QPrinter::doubleSidedPrinting() const-
1710{-
1711 return duplex() != DuplexNone;
executed 2 times by 1 test: return duplex() != DuplexNone;
Executed by:
  • tst_QPrinter
2
1712}-
1713-
1714/*!-
1715 \since 4.4-
1716-
1717 Enables double sided printing based on the \a duplex mode.-
1718-
1719 \sa duplex()-
1720*/-
1721void QPrinter::setDuplex(DuplexMode duplex)-
1722{-
1723 Q_D(QPrinter);-
1724 d->setProperty(QPrintEngine::PPK_Duplex, duplex);-
1725}
executed 2 times by 1 test: end of block
Executed by:
  • tst_QPrinter
2
1726-
1727/*!-
1728 \since 4.4-
1729-
1730 Returns the current duplex mode.-
1731-
1732 \sa setDuplex()-
1733*/-
1734QPrinter::DuplexMode QPrinter::duplex() const-
1735{-
1736 Q_D(const QPrinter);-
1737 return static_cast <DuplexMode> (d->printEngine->property(QPrintEngine::PPK_Duplex).toInt());
executed 8 times by 1 test: return static_cast <DuplexMode> (d->printEngine->property(QPrintEngine::PPK_Duplex).toInt());
Executed by:
  • tst_QPrinter
8
1738}-
1739-
1740/*!-
1741 \since 4.4-
1742-
1743 Returns the page's rectangle in \a unit; this is usually smaller-
1744 than the paperRect() since the page normally has margins between-
1745 its borders and the paper.-
1746-
1747 \sa paperSize()-
1748*/-
1749QRectF QPrinter::pageRect(Unit unit) const-
1750{-
1751 if (unit == QPrinter::DevicePixel)
unit == QPrinter::DevicePixelDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QPrinter
4-18
1752 return pageLayout().paintRectPixels(resolution());
executed 4 times by 1 test: return pageLayout().paintRectPixels(resolution());
Executed by:
  • tst_QPrinter
4
1753 else-
1754 return pageLayout().paintRect(QPageLayout::Unit(unit));
executed 18 times by 1 test: return pageLayout().paintRect(QPageLayout::Unit(unit));
Executed by:
  • tst_QPrinter
18
1755}-
1756-
1757-
1758/*!-
1759 \since 4.4-
1760-
1761 Returns the paper's rectangle in \a unit; this is usually larger-
1762 than the pageRect().-
1763-
1764 \sa pageRect()-
1765*/-
1766QRectF QPrinter::paperRect(Unit unit) const-
1767{-
1768 if (unit == QPrinter::DevicePixel)
unit == QPrinter::DevicePixelDescription
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QPrinter
0-18
1769 return pageLayout().fullRectPixels(resolution());
never executed: return pageLayout().fullRectPixels(resolution());
0
1770 else-
1771 return pageLayout().fullRect(QPageLayout::Unit(unit));
executed 18 times by 1 test: return pageLayout().fullRect(QPageLayout::Unit(unit));
Executed by:
  • tst_QPrinter
18
1772}-
1773-
1774/*!-
1775 \obsolete Use pageLayout().paintRectPixels(resolution()) instead.-
1776-
1777 Returns the page's rectangle; this is usually smaller than the-
1778 paperRect() since the page normally has margins between its-
1779 borders and the paper.-
1780-
1781 The unit of the returned rectangle is DevicePixel.-
1782-
1783 \sa pageLayout()-
1784*/-
1785QRect QPrinter::pageRect() const-
1786{-
1787 Q_D(const QPrinter);-
1788 return d->printEngine->property(QPrintEngine::PPK_PageRect).toRect();
executed 24 times by 1 test: return d->printEngine->property(QPrintEngine::PPK_PageRect).toRect();
Executed by:
  • tst_QPrinter
24
1789}-
1790-
1791/*!-
1792 \obsolete Use pageLayout().fullRectPixels(resolution()) instead.-
1793-
1794 Returns the paper's rectangle; this is usually larger than the-
1795 pageRect().-
1796-
1797 The unit of the returned rectangle is DevicePixel.-
1798-
1799 \sa pageLayout()-
1800*/-
1801QRect QPrinter::paperRect() const-
1802{-
1803 Q_D(const QPrinter);-
1804 return d->printEngine->property(QPrintEngine::PPK_PaperRect).toRect();
executed 78 times by 1 test: return d->printEngine->property(QPrintEngine::PPK_PaperRect).toRect();
Executed by:
  • tst_QPrinter
78
1805}-
1806-
1807/*!-
1808 \since 4.4-
1809-
1810 \obsolete Use setPageMargins(QMarginsF, QPageLayout::Unit) instead.-
1811-
1812 This function sets the \a left, \a top, \a right and \a bottom-
1813 page margins for this printer. The unit of the margins are-
1814 specified with the \a unit parameter.-
1815-
1816 \sa setPageMargins()-
1817*/-
1818void QPrinter::setPageMargins(qreal left, qreal top, qreal right, qreal bottom, QPrinter::Unit unit)-
1819{-
1820 if (unit == QPrinter::DevicePixel) {
unit == QPrinter::DevicePixelDescription
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_QPrinter
0-10
1821 QMarginsF margins = QMarginsF(left, top, right, bottom);-
1822 margins *= qt_pixelMultiplier(resolution());-
1823 margins = qt_convertMargins(margins, QPageLayout::Point, pageLayout().units());-
1824 setPageMargins(margins, pageLayout().units());-
1825 } else {
never executed: end of block
0
1826 setPageMargins(QMarginsF(left, top, right, bottom), QPageLayout::Unit(unit));-
1827 }
executed 10 times by 1 test: end of block
Executed by:
  • tst_QPrinter
10
1828}-
1829-
1830/*!-
1831 \reimp-
1832-
1833 \obsolete Use setPageMargins(QMarginsF, QPageLayout::Unit) instead.-
1834-
1835 \sa setPageMargins()-
1836 */-
1837void QPrinter::setMargins(const Margins &m)-
1838{-
1839 setPageMargins(QMarginsF(m.left, m.top, m.right, m.bottom), QPageLayout::Millimeter);-
1840}
executed 3 times by 1 test: end of block
Executed by:
  • tst_QPrinter
3
1841-
1842/*!-
1843 \since 4.4-
1844-
1845 \obsolete Use pageLayout().pageMargins() instead.-
1846-
1847 Returns the page margins for this printer in \a left, \a top, \a-
1848 right, \a bottom. The unit of the returned margins are specified-
1849 with the \a unit parameter.-
1850-
1851 \sa pageLayout(), setPageMargins()-
1852*/-
1853void QPrinter::getPageMargins(qreal *left, qreal *top, qreal *right, qreal *bottom, QPrinter::Unit unit) const-
1854{-
1855 QMarginsF margins;-
1856 if (unit == QPrinter::DevicePixel) {
unit == QPrinter::DevicePixelDescription
TRUEnever evaluated
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_QPrinter
0-42
1857 QMargins tmp = pageLayout().marginsPixels(resolution());-
1858 margins = QMarginsF(tmp.left(), tmp.top(), tmp.right(), tmp.bottom());-
1859 } else {
never executed: end of block
0
1860 margins = pageLayout().margins(QPageLayout::Unit(unit));-
1861 }
executed 42 times by 1 test: end of block
Executed by:
  • tst_QPrinter
42
1862 if (left)
leftDescription
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-42
1863 *left = margins.left();
executed 42 times by 1 test: *left = margins.left();
Executed by:
  • tst_QPrinter
42
1864 if (right)
rightDescription
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-42
1865 *right = margins.right();
executed 42 times by 1 test: *right = margins.right();
Executed by:
  • tst_QPrinter
42
1866 if (top)
topDescription
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-42
1867 *top = margins.top();
executed 42 times by 1 test: *top = margins.top();
Executed by:
  • tst_QPrinter
42
1868 if (bottom)
bottomDescription
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-42
1869 *bottom = margins.bottom();
executed 42 times by 1 test: *bottom = margins.bottom();
Executed by:
  • tst_QPrinter
42
1870}
executed 42 times by 1 test: end of block
Executed by:
  • tst_QPrinter
42
1871-
1872/*!-
1873 \internal-
1874-
1875 Returns the metric for the given \a id.-
1876*/-
1877int QPrinter::metric(PaintDeviceMetric id) const-
1878{-
1879 Q_D(const QPrinter);-
1880 return d->printEngine->metric(id);
executed 193 times by 1 test: return d->printEngine->metric(id);
Executed by:
  • tst_QPrinter
193
1881}-
1882-
1883/*!-
1884 Returns the paint engine used by the printer.-
1885*/-
1886QPaintEngine *QPrinter::paintEngine() const-
1887{-
1888 Q_D(const QPrinter);-
1889 return d->paintEngine;
executed 22 times by 1 test: return d->paintEngine;
Executed by:
  • tst_QPrinter
22
1890}-
1891-
1892/*!-
1893 \since 4.1-
1894-
1895 Returns the print engine used by the printer.-
1896*/-
1897QPrintEngine *QPrinter::printEngine() const-
1898{-
1899 Q_D(const QPrinter);-
1900 return d->printEngine;
never executed: return d->printEngine;
0
1901}-
1902-
1903/*!-
1904 \obsolete Use QPageSize::id(windowsId) and setPageLayout(QPageSize) instead.-
1905-
1906 Sets the page size to be used by the printer under Windows to \a-
1907 pageSize.-
1908-
1909 \sa pageLayout()-
1910*/-
1911void QPrinter::setWinPageSize(int pageSize)-
1912{-
1913 Q_D(QPrinter);-
1914 ABORT_IF_ACTIVE("QPrinter::setWinPageSize");
never executed: return;
d->printEngine...rinter::ActiveDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
0-1
1915 d->setProperty(QPrintEngine::PPK_WindowsPageSize, pageSize);-
1916}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
1917-
1918/*!-
1919 \obsolete Use pageLayout.pageSize().windowsId() instead.-
1920-
1921 Returns the page size used by the printer under Windows.-
1922-
1923 \sa pageLayout()-
1924*/-
1925int QPrinter::winPageSize() const-
1926{-
1927 Q_D(const QPrinter);-
1928 return d->printEngine->property(QPrintEngine::PPK_WindowsPageSize).toInt();
executed 2 times by 1 test: return d->printEngine->property(QPrintEngine::PPK_WindowsPageSize).toInt();
Executed by:
  • tst_QPrinter
2
1929}-
1930-
1931/*!-
1932 Returns a list of the resolutions (a list of dots-per-inch-
1933 integers) that the printer says it supports.-
1934-
1935 For X11 where all printing is directly to PDF, this-
1936 function will always return a one item list containing only the-
1937 PDF resolution, i.e., 72 (72 dpi -- but see PrinterMode).-
1938*/-
1939QList<int> QPrinter::supportedResolutions() const-
1940{-
1941 Q_D(const QPrinter);-
1942 QList<QVariant> varlist-
1943 = d->printEngine->property(QPrintEngine::PPK_SupportedResolutions).toList();-
1944 QList<int> intlist;-
1945 const int numSupportedResolutions = varlist.size();-
1946 intlist.reserve(numSupportedResolutions);-
1947 for (int i = 0; i < numSupportedResolutions; ++i)
i < numSupportedResolutionsDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
1
1948 intlist << varlist.at(i).toInt();
executed 1 time by 1 test: intlist << varlist.at(i).toInt();
Executed by:
  • tst_QPrinter
1
1949 return intlist;
executed 1 time by 1 test: return intlist;
Executed by:
  • tst_QPrinter
1
1950}-
1951-
1952/*!-
1953 Tells the printer to eject the current page and to continue-
1954 printing on a new page. Returns \c true if this was successful;-
1955 otherwise returns \c false.-
1956-
1957 Calling newPage() on an inactive QPrinter object will always-
1958 fail.-
1959*/-
1960bool QPrinter::newPage()-
1961{-
1962 Q_D(QPrinter);-
1963 if (d->printEngine->printerState() != QPrinter::Active)
d->printEngine...rinter::ActiveDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QPrinter
0-3
1964 return false;
never executed: return false;
0
1965 return d->printEngine->newPage();
executed 3 times by 1 test: return d->printEngine->newPage();
Executed by:
  • tst_QPrinter
3
1966}-
1967-
1968/*!-
1969 Aborts the current print run. Returns \c true if the print run was-
1970 successfully aborted and printerState() will return QPrinter::Aborted; otherwise-
1971 returns \c false.-
1972-
1973 It is not always possible to abort a print job. For example,-
1974 all the data has gone to the printer but the printer cannot or-
1975 will not cancel the job when asked to.-
1976*/-
1977bool QPrinter::abort()-
1978{-
1979 Q_D(QPrinter);-
1980 return d->printEngine->abort();
never executed: return d->printEngine->abort();
0
1981}-
1982-
1983/*!-
1984 Returns the current state of the printer. This may not always be-
1985 accurate (for example if the printer doesn't have the capability-
1986 of reporting its state to the operating system).-
1987*/-
1988QPrinter::PrinterState QPrinter::printerState() const-
1989{-
1990 Q_D(const QPrinter);-
1991 return d->printEngine->printerState();
never executed: return d->printEngine->printerState();
0
1992}-
1993-
1994#ifdef Q_OS_WIN-
1995/*!-
1996 Returns the supported paper sizes for this printer.-
1997-
1998 The values will be either a value that matches an entry in the-
1999 QPrinter::PaperSource enum or a driver spesific value. The driver-
2000 spesific values are greater than the constant DMBIN_USER declared-
2001 in wingdi.h.-
2002-
2003 \warning This function is only available in windows.-
2004*/-
2005-
2006QList<QPrinter::PaperSource> QPrinter::supportedPaperSources() const-
2007{-
2008 Q_D(const QPrinter);-
2009 QVariant v = d->printEngine->property(QPrintEngine::PPK_PaperSources);-
2010-
2011 QList<QVariant> variant_list = v.toList();-
2012 QList<QPrinter::PaperSource> int_list;-
2013 for (int i=0; i<variant_list.size(); ++i)-
2014 int_list << (QPrinter::PaperSource) variant_list.at(i).toInt();-
2015-
2016 return int_list;-
2017}-
2018-
2019#endif // Q_OS_WIN-
2020-
2021/*!-
2022 \fn QString QPrinter::printerSelectionOption() const-
2023-
2024 Returns the printer options selection string. This is useful only-
2025 if the print command has been explicitly set.-
2026-
2027 The default value (an empty string) implies that the printer should-
2028 be selected in a system-dependent manner.-
2029-
2030 Any other value implies that the given value should be used.-
2031-
2032 This function always returns an empty string on Windows and Mac.-
2033-
2034 \sa setPrinterSelectionOption(), setPrintProgram()-
2035*/-
2036-
2037QString QPrinter::printerSelectionOption() const-
2038{-
2039 Q_D(const QPrinter);-
2040 return d->printEngine->property(QPrintEngine::PPK_SelectionOption).toString();
executed 2 times by 1 test: return d->printEngine->property(QPrintEngine::PPK_SelectionOption).toString();
Executed by:
  • tst_QPrinter
2
2041}-
2042-
2043/*!-
2044 \fn void QPrinter::setPrinterSelectionOption(const QString &option)-
2045-
2046 Sets the printer to use \a option to select the printer. \a option-
2047 is null by default (which implies that Qt should be smart enough-
2048 to guess correctly), but it can be set to other values to use a-
2049 specific printer selection option.-
2050-
2051 If the printer selection option is changed while the printer is-
2052 active, the current print job may or may not be affected.-
2053-
2054 This function has no effect on Windows or Mac.-
2055-
2056 \sa printerSelectionOption(), setPrintProgram()-
2057*/-
2058-
2059void QPrinter::setPrinterSelectionOption(const QString &option)-
2060{-
2061 Q_D(QPrinter);-
2062 d->setProperty(QPrintEngine::PPK_SelectionOption, option);-
2063}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
2064-
2065/*!-
2066 \since 4.1-
2067 \fn int QPrinter::fromPage() const-
2068-
2069 Returns the number of the first page in a range of pages to be printed-
2070 (the "from page" setting). Pages in a document are numbered according to-
2071 the convention that the first page is page 1.-
2072-
2073 By default, this function returns a special value of 0, meaning that-
2074 the "from page" setting is unset.-
2075-
2076 \note If fromPage() and toPage() both return 0, this indicates that-
2077 \e{the whole document will be printed}.-
2078-
2079 \sa setFromTo(), toPage()-
2080*/-
2081-
2082int QPrinter::fromPage() const-
2083{-
2084 return d->fromPage;
executed 14 times by 2 tests: return d->fromPage;
Executed by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
14
2085}-
2086-
2087/*!-
2088 \since 4.1-
2089-
2090 Returns the number of the last page in a range of pages to be printed-
2091 (the "to page" setting). Pages in a document are numbered according to-
2092 the convention that the first page is page 1.-
2093-
2094 By default, this function returns a special value of 0, meaning that-
2095 the "to page" setting is unset.-
2096-
2097 \note If fromPage() and toPage() both return 0, this indicates that-
2098 \e{the whole document will be printed}.-
2099-
2100 The programmer is responsible for reading this setting and-
2101 printing accordingly.-
2102-
2103 \sa setFromTo(), fromPage()-
2104*/-
2105-
2106int QPrinter::toPage() const-
2107{-
2108 return d->toPage;
executed 13 times by 2 tests: return d->toPage;
Executed by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
13
2109}-
2110-
2111/*!-
2112 \since 4.1-
2113-
2114 Sets the range of pages to be printed to cover the pages with numbers-
2115 specified by \a from and \a to, where \a from corresponds to the first-
2116 page in the range and \a to corresponds to the last.-
2117-
2118 \note Pages in a document are numbered according to the convention that-
2119 the first page is page 1. However, if \a from and \a to are both set to 0,-
2120 the \e{whole document will be printed}.-
2121-
2122 This function is mostly used to set a default value that the user can-
2123 override in the print dialog when you call setup().-
2124-
2125 \sa fromPage(), toPage()-
2126*/-
2127-
2128void QPrinter::setFromTo(int from, int to)-
2129{-
2130 if (from > to) {
from > toDescription
TRUEnever evaluated
FALSEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
0-3
2131 qWarning() << "QPrinter::setFromTo: 'from' must be less than or equal to 'to'";-
2132 from = to;-
2133 }
never executed: end of block
0
2134 d->fromPage = from;-
2135 d->toPage = to;-
2136}
executed 3 times by 2 tests: end of block
Executed by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
3
2137-
2138/*!-
2139 \since 4.1-
2140-
2141 Sets the print range option in to be \a range.-
2142*/-
2143void QPrinter::setPrintRange( PrintRange range )-
2144{-
2145 d->printSelectionOnly = (range == Selection);-
2146-
2147 Q_D(QPrinter);-
2148 d->printRange = range;-
2149}
executed 5 times by 2 tests: end of block
Executed by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
5
2150-
2151/*!-
2152 \since 4.1-
2153-
2154 Returns the page range of the QPrinter. After the print setup-
2155 dialog has been opened, this function returns the value selected-
2156 by the user.-
2157-
2158 \sa setPrintRange()-
2159*/-
2160QPrinter::PrintRange QPrinter::printRange() const-
2161{-
2162 Q_D(const QPrinter);-
2163 return d->printRange;
executed 3 times by 1 test: return d->printRange;
Executed by:
  • tst_QPrinter
3
2164}-
2165-
2166-
2167/*!-
2168 \class QPrintEngine-
2169 \reentrant-
2170-
2171 \ingroup printing-
2172 \inmodule QtPrintSupport-
2173-
2174 \brief The QPrintEngine class defines an interface for how QPrinter-
2175 interacts with a given printing subsystem.-
2176-
2177 The common case when creating your own print engine is to derive from both-
2178 QPaintEngine and QPrintEngine. Various properties of a print engine are-
2179 given with property() and set with setProperty().-
2180-
2181 \sa QPaintEngine-
2182*/-
2183-
2184/*!-
2185 \enum QPrintEngine::PrintEnginePropertyKey-
2186-
2187 This enum is used to communicate properties between the print-
2188 engine and QPrinter. A property may or may not be supported by a-
2189 given print engine.-
2190-
2191 \value PPK_CollateCopies A boolean value indicating whether the-
2192 printout should be collated or not.-
2193-
2194 \value PPK_ColorMode Refers to QPrinter::ColorMode, either color or-
2195 monochrome.-
2196-
2197 \value PPK_Creator A string describing the document's creator.-
2198-
2199 \value PPK_Duplex A boolean value indicating whether both sides of-
2200 the printer paper should be used for the printout.-
2201-
2202 \value PPK_DocumentName A string describing the document name in-
2203 the spooler.-
2204-
2205 \value PPK_FontEmbedding A boolean value indicating whether data for-
2206 the document's fonts should be embedded in the data sent to the-
2207 printer.-
2208-
2209 \value PPK_FullPage A boolean describing if the printer should be-
2210 full page or not.-
2211-
2212 \value PPK_NumberOfCopies Obsolete. An integer specifying the number of-
2213 copies. Use PPK_CopyCount instead.-
2214-
2215 \value PPK_Orientation Specifies a QPrinter::Orientation value.-
2216-
2217 \value PPK_OutputFileName The output file name as a string. An-
2218 empty file name indicates that the printer should not print to a file.-
2219-
2220 \value PPK_PageOrder Specifies a QPrinter::PageOrder value.-
2221-
2222 \value PPK_PageRect A QRect specifying the page rectangle-
2223-
2224 \value PPK_PageSize Obsolete. Use PPK_PaperSize instead.-
2225-
2226 \value PPK_PaperRect A QRect specifying the paper rectangle.-
2227-
2228 \value PPK_PaperSource Specifies a QPrinter::PaperSource value.-
2229-
2230 \value PPK_PaperSources Specifies more than one QPrinter::PaperSource value.-
2231-
2232 \value PPK_PaperName A string specifying the name of the paper.-
2233-
2234 \value PPK_PaperSize Specifies a QPrinter::PaperSize value.-
2235-
2236 \value PPK_PrinterName A string specifying the name of the printer.-
2237-
2238 \value PPK_PrinterProgram A string specifying the name of the-
2239 printer program used for printing,-
2240-
2241 \value PPK_Resolution An integer describing the dots per inch for-
2242 this printer.-
2243-
2244 \value PPK_SelectionOption-
2245-
2246 \value PPK_SupportedResolutions A list of integer QVariants-
2247 describing the set of supported resolutions that the printer has.-
2248-
2249 \value PPK_WindowsPageSize An integer specifying a DM_PAPER entry-
2250 on Windows.-
2251-
2252 \value PPK_CustomPaperSize A QSizeF specifying a custom paper size-
2253 in the QPrinter::Point unit.-
2254-
2255 \value PPK_PageMargins A QList<QVariant> containing the left, top,-
2256 right and bottom margin values in the QPrinter::Point unit.-
2257-
2258 \value PPK_CopyCount An integer specifying the number of copies to print.-
2259-
2260 \value PPK_SupportsMultipleCopies A boolean value indicating whether or not-
2261 the printer supports printing multiple copies in one job.-
2262-
2263 \value PPK_QPageSize Set the page size using a QPageSize object.-
2264-
2265 \value PPK_QPageMargins Set the page margins using a QPair of QMarginsF and QPageLayout::Unit.-
2266-
2267 \value PPK_QPageLayout Set the page layout using a QPageLayout object.-
2268-
2269 \value PPK_CustomBase Basis for extension.-
2270*/-
2271-
2272/*!-
2273 \fn QPrintEngine::~QPrintEngine()-
2274-
2275 Destroys the print engine.-
2276*/-
2277-
2278/*!-
2279 \fn void QPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &value)-
2280-
2281 Sets the print engine's property specified by \a key to the given \a value.-
2282-
2283 \sa property()-
2284*/-
2285-
2286/*!-
2287 \fn void QPrintEngine::property(PrintEnginePropertyKey key) const-
2288-
2289 Returns the print engine's property specified by \a key.-
2290-
2291 \sa setProperty()-
2292*/-
2293-
2294/*!-
2295 \fn bool QPrintEngine::newPage()-
2296-
2297 Instructs the print engine to start a new page. Returns \c true if-
2298 the printer was able to create the new page; otherwise returns \c false.-
2299*/-
2300-
2301/*!-
2302 \fn bool QPrintEngine::abort()-
2303-
2304 Instructs the print engine to abort the printing process. Returns-
2305 true if successful; otherwise returns \c false.-
2306*/-
2307-
2308/*!-
2309 \fn int QPrintEngine::metric(QPaintDevice::PaintDeviceMetric id) const-
2310-
2311 Returns the metric for the given \a id.-
2312*/-
2313-
2314/*!-
2315 \fn QPrinter::PrinterState QPrintEngine::printerState() const-
2316-
2317 Returns the current state of the printer being used by the print engine.-
2318*/-
2319-
2320QT_END_NAMESPACE-
2321-
2322#endif // QT_NO_PRINTER-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9