Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qprinter.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#include "qprinter.h"
6#include "qprinter_p.h"
7
8#ifndef QT_NO_PRINTER
9
10#include <qpa/qplatformprintplugin.h>
11#include <qpa/qplatformprintersupport.h>
12
13#include "qprintengine.h"
14#include "qlist.h"
15#include <qcoreapplication.h>
16#include <qfileinfo.h>
17
18#include <private/qpagedpaintdevice_p.h>
19
21
22#include <qpicture.h>
23#if QT_CONFIG(printpreviewwidget)
24#include <private/qpaintengine_preview_p.h>
25#endif
26
28
29using namespace Qt::StringLiterals;
30
31#define ABORT_IF_ACTIVE(location)
32 if (d->printEngine->printerState() == QPrinter::Active) {
33 qWarning("%s: Cannot be changed while printer is active", location);
34 return;
35 }
36
37Q_GUI_EXPORT extern qreal qt_pixelMultiplier(int resolution);
38extern QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits);
39
40QPrinterInfo QPrinterPrivate::findValidPrinter(const QPrinterInfo &printer)
41{
42 // Try find a valid printer to use, either the one given, the default or the first available
43 QPrinterInfo printerToUse = printer;
44 if (printerToUse.isNull()) {
45 printerToUse = QPrinterInfo::defaultPrinter();
46 if (printerToUse.isNull()) {
47 QStringList availablePrinterNames = QPrinterInfo::availablePrinterNames();
48 if (!availablePrinterNames.isEmpty())
49 printerToUse = QPrinterInfo::printerInfo(availablePrinterNames.at(0));
50 }
51 }
52 return printerToUse;
53}
54
55void QPrinterPrivate::initEngines(QPrinter::OutputFormat format, const QPrinterInfo &printer)
56{
57 // Default to PdfFormat
58 outputFormat = QPrinter::PdfFormat;
59 QPlatformPrinterSupport *ps = nullptr;
60 QString printerName;
61
62 // Only set NativeFormat if we have a valid plugin and printer to use
63 if (format == QPrinter::NativeFormat) {
64 ps = QPlatformPrinterSupportPlugin::get();
65 QPrinterInfo printerToUse = findValidPrinter(printer);
66 if (ps && !printerToUse.isNull()) {
67 outputFormat = QPrinter::NativeFormat;
68 printerName = printerToUse.printerName();
69 }
70 }
71
72 if (outputFormat == QPrinter::NativeFormat) {
73 printEngine = ps->createNativePrintEngine(printerMode, printerName);
74 paintEngine = ps->createPaintEngine(printEngine, printerMode);
75 } else {
76 QPdfPrintEngine *pdfEngine = new QPdfPrintEngine(printerMode, pdfVersion);
77 paintEngine = pdfEngine;
78 printEngine = pdfEngine;
79 }
80
81 use_default_engine = true;
82 had_default_engines = true;
83 validPrinter = true;
84}
85
86void QPrinterPrivate::changeEngines(QPrinter::OutputFormat format, const QPrinterInfo &printer)
87{
88 QPrintEngine *oldPrintEngine = printEngine;
89 const bool def_engine = use_default_engine;
90
91 initEngines(format, printer);
92
93 if (oldPrintEngine) {
94 const auto properties = m_properties; // take a copy: setProperty() below modifies m_properties
95 for (const auto &key : properties) {
96 QVariant prop;
97 // PPK_NumberOfCopies need special treatmeant since it in most cases
98 // will return 1, disregarding the actual value that was set
99 // PPK_PrinterName also needs special treatment as initEngines has set it already
100 if (key == QPrintEngine::PPK_NumberOfCopies)
101 prop = QVariant(q_ptr->copyCount());
102 else if (key != QPrintEngine::PPK_PrinterName)
103 prop = oldPrintEngine->property(key);
104 if (prop.isValid())
105 setProperty(key, prop);
106 }
107 }
108
109 if (def_engine)
110 delete oldPrintEngine;
111}
112
113#if QT_CONFIG(printpreviewwidget)
114QList<const QPicture *> QPrinterPrivate::previewPages() const
115{
116 if (previewEngine)
117 return previewEngine->pages();
118 return QList<const QPicture *>();
119}
120
121bool QPrinterPrivate::previewMode() const
122{
123 return (previewEngine != nullptr) && (previewEngine == printEngine);
124}
125
126void QPrinterPrivate::setPreviewMode(bool enable)
127{
128 Q_Q(QPrinter);
129 if (enable) {
130 if (!previewEngine)
131 previewEngine = new QPreviewPaintEngine;
132 had_default_engines = use_default_engine;
133 use_default_engine = false;
134 realPrintEngine = printEngine;
135 realPaintEngine = paintEngine;
136 q->setEngines(previewEngine, previewEngine);
137 previewEngine->setProxyEngines(realPrintEngine, realPaintEngine);
138 } else {
139 q->setEngines(realPrintEngine, realPaintEngine);
140 use_default_engine = had_default_engines;
141 }
142}
143#endif // QT_CONFIG(printpreviewwidget)
144
145void QPrinterPrivate::setProperty(QPrintEngine::PrintEnginePropertyKey key, const QVariant &value)
146{
147 printEngine->setProperty(key, value);
148 m_properties.insert(key);
149}
150
151
153{
154public:
158
161
162 bool setPageLayout(const QPageLayout &newPageLayout) override
163 {
164 QPrinterPrivate *pd = QPrinterPrivate::get(m_printer);
165
166 if (pd->paintEngine->type() != QPaintEngine::Pdf
167 && pd->printEngine->printerState() == QPrinter::Active) {
168 qWarning("QPrinter::setPageLayout: Cannot be changed while printer is active");
169 return false;
170 }
171
172 // Try to set the print engine page layout
173 pd->setProperty(QPrintEngine::PPK_QPageLayout, QVariant::fromValue(newPageLayout));
174
175 return pageLayout().isEquivalentTo(newPageLayout);
176 }
177
178 bool setPageSize(const QPageSize &pageSize) override
179 {
180 QPrinterPrivate *pd = QPrinterPrivate::get(m_printer);
181
182 if (pd->paintEngine->type() != QPaintEngine::Pdf
183 && pd->printEngine->printerState() == QPrinter::Active) {
184 qWarning("QPrinter::setPageLayout: Cannot be changed while printer is active");
185 return false;
186 }
187
188
189 // Try to set the print engine page size
190 pd->setProperty(QPrintEngine::PPK_QPageSize, QVariant::fromValue(pageSize));
191
192 return pageLayout().pageSize().isEquivalentTo(pageSize);
193 }
194
195 bool setPageOrientation(QPageLayout::Orientation orientation) override
196 {
197 QPrinterPrivate *pd = QPrinterPrivate::get(m_printer);
198
199 // Set the print engine value
200 pd->setProperty(QPrintEngine::PPK_Orientation, orientation);
201
202 return pageLayout().orientation() == orientation;
203 }
204
205 bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units) override
206 {
207 QPrinterPrivate *pd = QPrinterPrivate::get(m_printer);
208
209 // Try to set print engine margins
210 std::pair<QMarginsF, QPageLayout::Unit> pair(margins, units);
211 pd->setProperty(QPrintEngine::PPK_QPageMargins, QVariant::fromValue(pair));
212
213 return pageLayout().margins() == margins && pageLayout().units() == units;
214 }
215
216 QPageLayout pageLayout() const override
217 {
218 QPrinterPrivate *pd = QPrinterPrivate::get(m_printer);
219
220 return qvariant_cast<QPageLayout>(pd->printEngine->property(QPrintEngine::PPK_QPageLayout));
221 }
222
224};
225
226
227/*!
228 \class QPrinter
229 \reentrant
230
231 \brief The QPrinter class is a paint device that paints on a printer.
232
233 \ingroup printing
234 \inmodule QtPrintSupport
235
236
237 This device represents a series of pages of printed output, and is
238 used in almost exactly the same way as other paint devices such as
239 QWidget and QPixmap.
240 A set of additional functions are provided to manage device-specific
241 features, such as orientation and resolution, and to step through
242 the pages in a document as it is generated.
243
244 When printing directly to a printer on Windows or \macos, QPrinter uses
245 the built-in printer drivers. On X11, QPrinter uses the
246 \l{Common Unix Printing System (CUPS)}
247 to send PDF output to the printer. As an alternative,
248 the printProgram() function can be used to specify the command or utility
249 to use instead of the system default.
250
251 Note that setting parameters like paper size and resolution on an
252 invalid printer is undefined. You can use QPrinter::isValid() to
253 verify this before changing any parameters.
254
255 QPrinter supports a number of parameters, most of which can be
256 changed by the end user through a \l{QPrintDialog}{print dialog}. In
257 general, QPrinter passes these functions onto the underlying QPrintEngine.
258
259 The most important parameters are:
260 \list
261 \li setPageLayout() tells QPrinter which page orientation to use, and
262 what size to expect from the printer.
263 \li setResolution() tells QPrinter what resolution you wish the
264 printer to provide, in dots per inch (DPI).
265 \li setFullPage() tells QPrinter whether you want to deal with the
266 full page or just with the part the printer can draw on.
267 \li setCopyCount() tells QPrinter how many copies of the document
268 it should print.
269 \endlist
270
271 Many of these functions can only be called before the actual printing
272 begins (i.e., before QPainter::begin() is called). This usually makes
273 sense because, for example, it's not possible to change the number of
274 copies when you are halfway through printing. There are also some
275 settings that the user sets (through the printer dialog) and that
276 applications are expected to obey. See QAbstractPrintDialog's
277 documentation for more details.
278
279 When QPainter::begin() is called, the QPrinter it operates on is prepared for
280 a new page, enabling the QPainter to be used immediately to paint the first
281 page in a document. Once the first page has been painted, newPage() can be
282 called to request a new blank page to paint on, or QPainter::end() can be
283 called to finish printing. The second page and all following pages are
284 prepared using a call to newPage() before they are painted.
285
286 The first page in a document does not need to be preceded by a call to
287 newPage(). You only need to calling newPage() after QPainter::begin() if you
288 need to insert a blank page at the beginning of a printed document.
289 Similarly, calling newPage() after the last page in a document is painted will
290 result in a trailing blank page appended to the end of the printed document.
291
292 If you want to abort the print job, abort() will try its best to
293 stop printing. It may cancel the entire job or just part of it.
294
295 Since QPrinter can print to any QPrintEngine subclass, it is possible to
296 extend printing support to cover new types of printing subsystem by
297 subclassing QPrintEngine and reimplementing its interface.
298
299 \sa QPrintDialog, {Qt Print Support}
300*/
301
302/*!
303 \enum QPrinter::PrinterState
304
305 \value Idle
306 \value Active
307 \value Aborted
308 \value Error
309*/
310
311/*!
312 \enum QPrinter::PrinterMode
313
314 This enum describes the mode the printer should work in. It
315 basically presets a certain resolution and working mode.
316
317 \value ScreenResolution Sets the resolution of the print device to
318 the screen resolution. This has the big advantage that the results
319 obtained when painting on the printer will match more or less
320 exactly the visible output on the screen. It is the easiest to
321 use, as font metrics on the screen and on the printer are the
322 same. This is the default value. ScreenResolution will produce a
323 lower quality output than HighResolution and should only be used
324 for drafts.
325
326 \value PrinterResolution This value is deprecated. For printers,
327 it is equivalent to ScreenResolution on Unix and HighResolution
328 on Windows and macOS. For PDF printing, it is not supported and
329 may result in undefined behavior. Using this value can lead to
330 non-portable printer code.
331
332 \value HighResolution On Windows, sets the printer resolution to that
333 defined for the printer in use. For PDF printing, sets the
334 resolution of the PDF driver to 1200 dpi.
335
336 \note When rendering text on a QPrinter device, it is important
337 to realize that the size of text, when specified in points, is
338 independent of the resolution specified for the device itself.
339 Therefore, it may be useful to specify the font size in pixels
340 when combining text with graphics to ensure that their relative
341 sizes are what you expect.
342*/
343
344/*!
345 \enum QPrinter::PrintRange
346
347 Used to specify the print range selection option.
348
349 \value AllPages All pages should be printed.
350 \value Selection Only the selection should be printed.
351 \value PageRange The specified page range should be printed.
352 \value CurrentPage Only the current page should be printed.
353
354 \sa setPrintRange(), printRange(), QAbstractPrintDialog::PrintRange
355*/
356
357/*!
358 \enum QPrinter::PageOrder
359
360 This enum type is used by QPrinter to tell the application program
361 how to print.
362
363 \value FirstPageFirst the lowest-numbered page should be printed
364 first.
365
366 \value LastPageFirst the highest-numbered page should be printed
367 first.
368*/
369
370/*!
371 \enum QPrinter::ColorMode
372
373 This enum type is used to indicate whether QPrinter should print
374 in color or not.
375
376 \value Color print in color if available, otherwise in grayscale.
377
378 \value GrayScale print in grayscale, even on color printers.
379*/
380
381/*!
382 \enum QPrinter::PaperSource
383
384 This enum type specifies what paper source QPrinter is to use.
385 QPrinter does not check that the paper source is available; it
386 just uses this information to try and set the paper source.
387 Whether it will set the paper source depends on whether the
388 printer has that particular source.
389
390 \warning This is currently only implemented for Windows.
391
392 \value Auto
393 \value Cassette
394 \value Envelope
395 \value EnvelopeManual
396 \value FormSource
397 \value LargeCapacity
398 \value LargeFormat
399 \value Lower
400 \value MaxPageSource Deprecated, use LastPaperSource instead
401 \value Middle
402 \value Manual
403 \value OnlyOne
404 \value Tractor
405 \value SmallFormat
406 \value Upper
407 \value CustomSource A PaperSource defined by the printer that is unknown to Qt
408 \value LastPaperSource The highest valid PaperSource value, currently CustomSource
409*/
410
411/*!
412 \enum QPrinter::Unit
413 \since 4.4
414
415 This enum type is used to specify the measurement unit for page and
416 paper sizes.
417
418 \value Millimeter
419 \value Point
420 \value Inch
421 \value Pica
422 \value Didot
423 \value Cicero
424 \value DevicePixel
425
426 Note the difference between Point and DevicePixel. The Point unit is
427 defined to be 1/72th of an inch, while the DevicePixel unit is
428 resolution dependent and is based on the actual pixels, or dots, on
429 the printer.
430*/
431
432/*!
433 Creates a new printer object with the given \a mode.
434*/
435QPrinter::QPrinter(PrinterMode mode)
436 : QPagedPaintDevice(new QPrinterPagedPaintDevicePrivate(this)),
437 d_ptr(new QPrinterPrivate(this))
438{
439 d_ptr->init(QPrinterInfo(), mode);
440}
441
442/*!
443 \since 4.4
444
445 Creates a new printer object with the given \a printer and \a mode.
446*/
447QPrinter::QPrinter(const QPrinterInfo& printer, PrinterMode mode)
448 : QPagedPaintDevice(new QPrinterPagedPaintDevicePrivate(this)),
449 d_ptr(new QPrinterPrivate(this))
450{
451 d_ptr->init(printer, mode);
452}
453
454QPrinterPrivate::~QPrinterPrivate()
455 = default;
456
457void QPrinterPrivate::init(const QPrinterInfo &printer, QPrinter::PrinterMode mode)
458{
459 if (Q_UNLIKELY(!QCoreApplication::instance())) {
460 qFatal("QPrinter: Must construct a QCoreApplication before a QPrinter");
461 return;
462 }
463
464 printerMode = mode;
465
466 initEngines(QPrinter::NativeFormat, printer);
467}
468
469/*!
470 This function is used by subclasses of QPrinter to specify custom
471 print and paint engines (\a printEngine and \a paintEngine,
472 respectively).
473
474 QPrinter does not take ownership of the engines, so you need to
475 manage these engine instances yourself.
476
477 Note that changing the engines will reset the printer state and
478 all its properties.
479
480 \sa printEngine(), paintEngine(), setOutputFormat()
481
482 \since 4.1
483*/
484void QPrinter::setEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine)
485{
486 Q_D(QPrinter);
487
488 if (d->use_default_engine)
489 delete d->printEngine;
490
491 d->printEngine = printEngine;
492 d->paintEngine = paintEngine;
493 d->use_default_engine = false;
494}
495
496/*!
497 Destroys the printer object and frees any allocated resources. If
498 the printer is destroyed while a print job is in progress this may
499 or may not affect the print job.
500*/
501QPrinter::~QPrinter()
502{
503 Q_D(QPrinter);
504 if (d->use_default_engine)
505 delete d->printEngine;
506#if QT_CONFIG(printpreviewwidget)
507 delete d->previewEngine;
508#endif
509}
510
511/*!
512 \enum QPrinter::OutputFormat
513
514 The OutputFormat enum is used to describe the format QPrinter should
515 use for printing.
516
517 \value NativeFormat QPrinter will print output using a method defined
518 by the platform it is running on. This mode is the default when printing
519 directly to a printer.
520
521 \value PdfFormat QPrinter will generate its output as a searchable PDF file.
522 This mode is the default when printing to a file.
523
524 \sa outputFormat(), setOutputFormat(), setOutputFileName()
525*/
526
527/*!
528 \since 4.1
529
530 Sets the output format for this printer to \a format.
531
532 If \a format is the same value as currently set then no change will be made.
533
534 If \a format is NativeFormat then the printerName will be set to the default
535 printer. If there are no valid printers configured then no change will be made.
536 If you want to set NativeFormat with a specific printerName then use
537 setPrinterName().
538
539 \sa setPrinterName()
540*/
541void QPrinter::setOutputFormat(OutputFormat format)
542{
543 Q_D(QPrinter);
544
545 if (d->outputFormat == format)
546 return;
547
548 if (format == QPrinter::NativeFormat) {
549 QPrinterInfo printerToUse = d->findValidPrinter();
550 if (!printerToUse.isNull())
551 d->changeEngines(format, printerToUse);
552 } else {
553 d->changeEngines(format, QPrinterInfo());
554 }
555}
556
557/*!
558 \since 4.1
559
560 Returns the output format for this printer.
561*/
562QPrinter::OutputFormat QPrinter::outputFormat() const
563{
564 Q_D(const QPrinter);
565 return d->outputFormat;
566}
567
568/*!
569 \since 5.10
570
571 Sets the PDF version for this printer to \a version.
572
573 If \a version is the same value as currently set then no change will be made.
574*/
575void QPrinter::setPdfVersion(PdfVersion version)
576{
577 Q_D(QPrinter);
578
579 if (d->pdfVersion == version)
580 return;
581
582 d->pdfVersion = version;
583
584 if (d->outputFormat == QPrinter::PdfFormat) {
585 d->changeEngines(d->outputFormat, QPrinterInfo());
586 }
587}
588
589/*!
590 \since 5.10
591
592 Returns the PDF version for this printer. The default is \c PdfVersion_1_4.
593*/
594QPrinter::PdfVersion QPrinter::pdfVersion() const
595{
596 Q_D(const QPrinter);
597 return d->pdfVersion;
598}
599
600/*! \internal
601*/
602int QPrinter::devType() const
603{
604 return QInternal::Printer;
605}
606
607/*!
608 Returns the printer name. This value is initially set to the name
609 of the default printer.
610
611 \sa setPrinterName()
612*/
613QString QPrinter::printerName() const
614{
615 Q_D(const QPrinter);
616 return d->printEngine->property(QPrintEngine::PPK_PrinterName).toString();
617}
618
619/*!
620 Sets the printer name to \a name.
621
622 If the \a name is empty then the output format will be set to PdfFormat.
623
624 If the \a name is not a valid printer then no change will be made.
625
626 If the \a name is a valid printer then the output format will be set to NativeFormat.
627
628 \sa printerName(), isValid(), setOutputFormat()
629*/
630void QPrinter::setPrinterName(const QString &name)
631{
632 Q_D(QPrinter);
633 ABORT_IF_ACTIVE("QPrinter::setPrinterName");
634
635 if (printerName() == name)
636 return;
637
638 if (name.isEmpty()) {
639 setOutputFormat(QPrinter::PdfFormat);
640 return;
641 }
642
643 QPrinterInfo printerToUse = QPrinterInfo::printerInfo(name);
644 if (printerToUse.isNull())
645 return;
646
647 if (outputFormat() == QPrinter::PdfFormat) {
648 d->changeEngines(QPrinter::NativeFormat, printerToUse);
649 } else {
650 d->setProperty(QPrintEngine::PPK_PrinterName, name);
651 }
652}
653
654/*!
655 \since 4.4
656
657 Returns \c true if the printer currently selected is a valid printer
658 in the system, or a pure PDF printer; otherwise returns \c false.
659
660 To detect other failures check the output of QPainter::begin() or QPrinter::newPage().
661
662 \snippet printing-qprinter/errors.cpp 0
663
664 \sa setPrinterName()
665*/
666bool QPrinter::isValid() const
667{
668 Q_D(const QPrinter);
669 if (!qApp)
670 return false;
671 return d->validPrinter;
672}
673
674/*!
675 \fn QString QPrinter::outputFileName() const
676
677 Returns the name of the output file. By default, this is an empty string
678 (indicating that the printer shouldn't print to file).
679
680 \sa QPrintEngine::PrintEnginePropertyKey
681
682*/
683
684QString QPrinter::outputFileName() const
685{
686 Q_D(const QPrinter);
687 return d->printEngine->property(QPrintEngine::PPK_OutputFileName).toString();
688}
689
690/*!
691 Sets the name of the output file to \a fileName.
692
693 Setting a null or empty name (0 or "") disables printing to a file.
694 Setting a non-empty name enables printing to a file.
695
696 This can change the value of outputFormat().
697 If the file name has the ".pdf" suffix PDF is generated. If the file name
698 has a suffix other than ".pdf", the output format used is the
699 one set with setOutputFormat().
700
701 QPrinter uses Qt's cross-platform PDF print engines
702 respectively. If you can produce this format natively, for example
703 \macos can generate PDF's from its print engine, set the output format
704 back to NativeFormat.
705
706 \sa outputFileName(), setOutputFormat()
707*/
708
709void QPrinter::setOutputFileName(const QString &fileName)
710{
711 Q_D(QPrinter);
712 ABORT_IF_ACTIVE("QPrinter::setOutputFileName");
713
714 QFileInfo fi(fileName);
715 if (!fi.suffix().compare("pdf"_L1, Qt::CaseInsensitive))
716 setOutputFormat(QPrinter::PdfFormat);
717 else if (fileName.isEmpty())
718 setOutputFormat(QPrinter::NativeFormat);
719
720 d->setProperty(QPrintEngine::PPK_OutputFileName, fileName);
721}
722
723
724/*!
725 Returns the name of the program that sends the print output to the
726 printer.
727
728 The default is to return an empty string; meaning that QPrinter will try to
729 be smart in a system-dependent way. On X11 only, you can set it to something
730 different to use a specific print program. On the other platforms, this
731 returns an empty string.
732
733 \sa setPrintProgram(), setPrinterSelectionOption()
734*/
735QString QPrinter::printProgram() const
736{
737 Q_D(const QPrinter);
738 return d->printEngine->property(QPrintEngine::PPK_PrinterProgram).toString();
739}
740
741
742/*!
743 Sets the name of the program that should do the print job to \a
744 printProg.
745
746 On X11, this function sets the program to call with the PDF
747 output. On other platforms, it has no effect.
748
749 \sa printProgram()
750*/
751void QPrinter::setPrintProgram(const QString &printProg)
752{
753 Q_D(QPrinter);
754 ABORT_IF_ACTIVE("QPrinter::setPrintProgram");
755 d->setProperty(QPrintEngine::PPK_PrinterProgram, printProg);
756}
757
758
759/*!
760 Returns the document name.
761
762 \sa setDocName(), QPrintEngine::PrintEnginePropertyKey
763*/
764QString QPrinter::docName() const
765{
766 Q_D(const QPrinter);
767 return d->printEngine->property(QPrintEngine::PPK_DocumentName).toString();
768}
769
770
771/*!
772 Sets the document name to \a name.
773
774 On X11, the document name is for example used as the default
775 output filename in QPrintDialog. Note that the document name does
776 not affect the file name if the printer is printing to a file.
777 Use the setOutputFile() function for this.
778
779 \sa docName(), QPrintEngine::PrintEnginePropertyKey
780*/
781void QPrinter::setDocName(const QString &name)
782{
783 Q_D(QPrinter);
784 ABORT_IF_ACTIVE("QPrinter::setDocName");
785 d->setProperty(QPrintEngine::PPK_DocumentName, name);
786}
787
788
789/*!
790 Returns the name of the application that created the document.
791
792 \sa setCreator()
793*/
794QString QPrinter::creator() const
795{
796 Q_D(const QPrinter);
797 return d->printEngine->property(QPrintEngine::PPK_Creator).toString();
798}
799
800
801/*!
802 Sets the name of the application that created the document to \a
803 creator.
804
805 This function is only applicable to the X11 version of Qt. If no
806 creator name is specified, the creator will be set to "Qt"
807 followed by some version number.
808
809 \sa creator()
810*/
811void QPrinter::setCreator(const QString &creator)
812{
813 Q_D(QPrinter);
814 ABORT_IF_ACTIVE("QPrinter::setCreator");
815 d->setProperty(QPrintEngine::PPK_Creator, creator);
816}
817
818/*!
819 Sets the page order to \a pageOrder.
820
821 The page order can be QPrinter::FirstPageFirst or
822 QPrinter::LastPageFirst. The application is responsible for
823 reading the page order and printing accordingly.
824
825 This function is mostly useful for setting a default value that
826 the user can override in the print dialog.
827
828 This function is only supported under X11.
829*/
830
831void QPrinter::setPageOrder(PageOrder pageOrder)
832{
833 d->pageOrderAscending = (pageOrder == FirstPageFirst);
834
835 Q_D(QPrinter);
836 ABORT_IF_ACTIVE("QPrinter::setPageOrder");
837 d->setProperty(QPrintEngine::PPK_PageOrder, pageOrder);
838}
839
840
841/*!
842 Returns the current page order.
843
844 The default page order is \c FirstPageFirst.
845*/
846
847QPrinter::PageOrder QPrinter::pageOrder() const
848{
849 Q_D(const QPrinter);
850 return QPrinter::PageOrder(d->printEngine->property(QPrintEngine::PPK_PageOrder).toInt());
851}
852
853
854/*!
855 Sets the printer's color mode to \a newColorMode, which can be
856 either \c Color or \c GrayScale.
857
858 \sa colorMode()
859*/
860
861void QPrinter::setColorMode(ColorMode newColorMode)
862{
863 Q_D(QPrinter);
864 ABORT_IF_ACTIVE("QPrinter::setColorMode");
865 d->setProperty(QPrintEngine::PPK_ColorMode, newColorMode);
866}
867
868
869/*!
870 Returns the current color mode.
871
872 \sa setColorMode()
873*/
874QPrinter::ColorMode QPrinter::colorMode() const
875{
876 Q_D(const QPrinter);
877 return QPrinter::ColorMode(d->printEngine->property(QPrintEngine::PPK_ColorMode).toInt());
878}
879
880/*!
881 \since 4.7
882
883 Sets the number of copies to be printed to \a count.
884
885 The printer driver reads this setting and prints the specified number of
886 copies.
887
888 \sa copyCount(), supportsMultipleCopies()
889*/
890
891void QPrinter::setCopyCount(int count)
892{
893 Q_D(QPrinter);
894 ABORT_IF_ACTIVE("QPrinter::setCopyCount;");
895 d->setProperty(QPrintEngine::PPK_CopyCount, count);
896}
897
898/*!
899 \since 4.7
900
901 Returns the number of copies that will be printed. The default value is 1.
902
903 \sa setCopyCount(), supportsMultipleCopies()
904*/
905
906int QPrinter::copyCount() const
907{
908 Q_D(const QPrinter);
909 return d->printEngine->property(QPrintEngine::PPK_CopyCount).toInt();
910}
911
912/*!
913 \since 4.7
914
915 Returns \c true if the printer supports printing multiple copies of the same
916 document in one job; otherwise false is returned.
917
918 On most systems this function will return true. However, on X11 systems
919 that do not support CUPS, this function will return false. That means the
920 application has to handle the number of copies by printing the same
921 document the required number of times.
922
923 \sa setCopyCount(), copyCount()
924*/
925
926bool QPrinter::supportsMultipleCopies() const
927{
928 Q_D(const QPrinter);
929 return d->printEngine->property(QPrintEngine::PPK_SupportsMultipleCopies).toBool();
930}
931
932/*!
933 \since 4.1
934
935 Returns \c true if collation is turned on when multiple copies is selected.
936 Returns \c false if it is turned off when multiple copies is selected.
937 When collating is turned off the printing of each individual page will be repeated
938 the numCopies() amount before the next page is started. With collating turned on
939 all pages are printed before the next copy of those pages is started.
940
941 \sa setCollateCopies()
942*/
943bool QPrinter::collateCopies() const
944{
945 Q_D(const QPrinter);
946 return d->printEngine->property(QPrintEngine::PPK_CollateCopies).toBool();
947}
948
949
950/*!
951 \since 4.1
952
953 Sets the default value for collation checkbox when the print
954 dialog appears. If \a collate is true, it will enable
955 setCollateCopiesEnabled(). The default value is false. This value
956 will be changed by what the user presses in the print dialog.
957
958 \sa collateCopies()
959*/
960void QPrinter::setCollateCopies(bool collate)
961{
962 Q_D(QPrinter);
963 ABORT_IF_ACTIVE("QPrinter::setCollateCopies");
964 d->setProperty(QPrintEngine::PPK_CollateCopies, collate);
965}
966
967
968
969/*!
970 If \a fp is true, enables support for painting over the entire page;
971 otherwise restricts painting to the printable area reported by the
972 device.
973
974 By default, full page printing is disabled. In this case, the origin
975 of the QPrinter's coordinate system coincides with the top-left
976 corner of the printable area.
977
978 If full page printing is enabled, the origin of the QPrinter's
979 coordinate system coincides with the top-left corner of the paper
980 itself. In this case, the
981 \l{QPaintDevice::PaintDeviceMetric}{device metrics} will report
982 the exact same dimensions as indicated by \{QPageSize}. It may not
983 be possible to print on the entire physical page because of the
984 printer's margins, so the application must account for the margins
985 itself.
986
987 \sa fullPage(), QPagedPaintDevice::pageLayout(), QPagedPaintDevice::setPageSize()
988*/
989
990void QPrinter::setFullPage(bool fp)
991{
992 Q_D(QPrinter);
993 // Set the print engine
994 d->setProperty(QPrintEngine::PPK_FullPage, fp);
995}
996
997
998/*!
999 Returns \c true if the origin of the printer's coordinate system is
1000 at the corner of the page and false if it is at the edge of the
1001 printable area.
1002
1003 See setFullPage() for details and caveats.
1004
1005 \sa setFullPage(), QPagedPaintDevice::pageLayout()
1006*/
1007
1008bool QPrinter::fullPage() const
1009{
1010 Q_D(const QPrinter);
1011 return d->printEngine->property(QPrintEngine::PPK_FullPage).toBool();
1012}
1013
1014
1015/*!
1016 Requests that the printer prints at \a dpi or as near to \a dpi as
1017 possible.
1018
1019 This setting affects the coordinate system as returned by, for
1020 example QPainter::viewport().
1021
1022 This function must be called before QPainter::begin() to have an effect on
1023 all platforms.
1024
1025 \sa resolution(), QPagedPaintDevice::setPageSize()
1026*/
1027
1028void QPrinter::setResolution(int dpi)
1029{
1030 Q_D(QPrinter);
1031 ABORT_IF_ACTIVE("QPrinter::setResolution");
1032 d->setProperty(QPrintEngine::PPK_Resolution, dpi);
1033}
1034
1035
1036/*!
1037 Returns the current assumed resolution of the printer, as set by
1038 setResolution() or by the printer driver.
1039
1040 \sa setResolution()
1041*/
1042
1043int QPrinter::resolution() const
1044{
1045 Q_D(const QPrinter);
1046 return d->printEngine->property(QPrintEngine::PPK_Resolution).toInt();
1047}
1048
1049/*!
1050 Sets the paper source setting to \a source.
1051
1052 Windows only: This option can be changed while printing and will
1053 take effect from the next call to newPage()
1054
1055 \sa paperSource()
1056*/
1057
1058void QPrinter::setPaperSource(PaperSource source)
1059{
1060 Q_D(QPrinter);
1061 d->setProperty(QPrintEngine::PPK_PaperSource, source);
1062}
1063
1064/*!
1065 Returns the printer's paper source. This is \c Manual or a printer
1066 tray or paper cassette.
1067*/
1068QPrinter::PaperSource QPrinter::paperSource() const
1069{
1070 Q_D(const QPrinter);
1071 return QPrinter::PaperSource(d->printEngine->property(QPrintEngine::PPK_PaperSource).toInt());
1072}
1073
1074
1075/*!
1076 \since 4.1
1077
1078 Enabled or disables font embedding depending on \a enable.
1079
1080 \sa fontEmbeddingEnabled()
1081*/
1082void QPrinter::setFontEmbeddingEnabled(bool enable)
1083{
1084 Q_D(QPrinter);
1085 d->setProperty(QPrintEngine::PPK_FontEmbedding, enable);
1086}
1087
1088/*!
1089 \since 4.1
1090
1091 Returns \c true if font embedding is enabled.
1092
1093 \sa setFontEmbeddingEnabled()
1094*/
1095bool QPrinter::fontEmbeddingEnabled() const
1096{
1097 Q_D(const QPrinter);
1098 return d->printEngine->property(QPrintEngine::PPK_FontEmbedding).toBool();
1099}
1100
1101/*!
1102 \enum QPrinter::DuplexMode
1103 \since 4.4
1104
1105 This enum is used to indicate whether printing will occur on one or both sides
1106 of each sheet of paper (simplex or duplex printing).
1107
1108 \value DuplexNone Single sided (simplex) printing only.
1109 \value DuplexAuto The printer's default setting is used to determine whether
1110 duplex printing is used.
1111 \value DuplexLongSide Both sides of each sheet of paper are used for printing.
1112 The paper is turned over its longest edge before the second
1113 side is printed
1114 \value DuplexShortSide Both sides of each sheet of paper are used for printing.
1115 The paper is turned over its shortest edge before the second
1116 side is printed
1117*/
1118
1119/*!
1120 \since 4.4
1121
1122 Enables double sided printing based on the \a duplex mode.
1123
1124 \sa duplex()
1125*/
1126void QPrinter::setDuplex(DuplexMode duplex)
1127{
1128 Q_D(QPrinter);
1129 d->setProperty(QPrintEngine::PPK_Duplex, duplex);
1130}
1131
1132/*!
1133 \since 4.4
1134
1135 Returns the current duplex mode.
1136
1137 \sa setDuplex()
1138*/
1139QPrinter::DuplexMode QPrinter::duplex() const
1140{
1141 Q_D(const QPrinter);
1142 return static_cast <DuplexMode> (d->printEngine->property(QPrintEngine::PPK_Duplex).toInt());
1143}
1144
1145/*!
1146 \since 4.4
1147
1148 Returns the page's rectangle in \a unit; this is usually smaller
1149 than the paperRect() since the page normally has margins between
1150 its borders and the paper.
1151
1152 \sa QPagedPaintDevice::pageLayout()
1153*/
1154QRectF QPrinter::pageRect(Unit unit) const
1155{
1156 if (unit == QPrinter::DevicePixel)
1157 return pageLayout().paintRectPixels(resolution());
1158 else
1159 return pageLayout().paintRect(QPageLayout::Unit(unit));
1160}
1161
1162
1163/*!
1164 \since 4.4
1165
1166 Returns the paper's rectangle in \a unit; this is usually larger
1167 than the pageRect().
1168
1169 \sa pageRect()
1170*/
1171QRectF QPrinter::paperRect(Unit unit) const
1172{
1173 if (unit == QPrinter::DevicePixel)
1174 return pageLayout().fullRectPixels(resolution());
1175 else
1176 return pageLayout().fullRect(QPageLayout::Unit(unit));
1177}
1178
1179/*!
1180 \internal
1181
1182 Returns the metric for the given \a id.
1183*/
1184int QPrinter::metric(PaintDeviceMetric id) const
1185{
1186 Q_D(const QPrinter);
1187 return d->printEngine->metric(id);
1188}
1189
1190/*!
1191 Returns the paint engine used by the printer.
1192*/
1193QPaintEngine *QPrinter::paintEngine() const
1194{
1195 Q_D(const QPrinter);
1196 return d->paintEngine;
1197}
1198
1199/*!
1200 \since 4.1
1201
1202 Returns the print engine used by the printer.
1203*/
1204QPrintEngine *QPrinter::printEngine() const
1205{
1206 Q_D(const QPrinter);
1207 return d->printEngine;
1208}
1209
1210/*!
1211 Returns a list of the resolutions (a list of dots-per-inch
1212 integers) that the printer says it supports.
1213
1214 For X11 where all printing is directly to PDF, this
1215 function will always return a one item list containing only the
1216 PDF resolution, i.e., 72 (72 dpi -- but see PrinterMode).
1217*/
1218QList<int> QPrinter::supportedResolutions() const
1219{
1220 Q_D(const QPrinter);
1221 const QList<QVariant> varlist
1222 = d->printEngine->property(QPrintEngine::PPK_SupportedResolutions).toList();
1223 QList<int> intlist;
1224 intlist.reserve(varlist.size());
1225 for (const auto &var : varlist)
1226 intlist << var.toInt();
1227 return intlist;
1228}
1229
1230/*!
1231 Tells the printer to eject the current page and to continue
1232 printing on a new page. Returns \c true if this was successful;
1233 otherwise returns \c false.
1234
1235 Calling newPage() on an inactive QPrinter object will always
1236 fail.
1237*/
1238bool QPrinter::newPage()
1239{
1240 Q_D(QPrinter);
1241 if (d->printEngine->printerState() != QPrinter::Active)
1242 return false;
1243 return d->printEngine->newPage();
1244}
1245
1246/*!
1247 Aborts the current print run. Returns \c true if the print run was
1248 successfully aborted and printerState() will return QPrinter::Aborted; otherwise
1249 returns \c false.
1250
1251 It is not always possible to abort a print job. For example,
1252 all the data has gone to the printer but the printer cannot or
1253 will not cancel the job when asked to.
1254*/
1255bool QPrinter::abort()
1256{
1257 Q_D(QPrinter);
1258 return d->printEngine->abort();
1259}
1260
1261/*!
1262 Returns the current state of the printer. This may not always be
1263 accurate (for example if the printer doesn't have the capability
1264 of reporting its state to the operating system).
1265*/
1266QPrinter::PrinterState QPrinter::printerState() const
1267{
1268 Q_D(const QPrinter);
1269 return d->printEngine->printerState();
1270}
1271
1272#if defined(Q_OS_WIN) || defined(Q_QDOC)
1273/*!
1274 Returns the supported paper sizes for this printer.
1275
1276 The values will be either a value that matches an entry in the
1277 QPrinter::PaperSource enum or a driver spesific value. The driver
1278 spesific values are greater than the constant DMBIN_USER declared
1279 in wingdi.h.
1280
1281 \warning This function is only available in windows.
1282*/
1283
1284QList<QPrinter::PaperSource> QPrinter::supportedPaperSources() const
1285{
1286 Q_D(const QPrinter);
1287 QVariant v = d->printEngine->property(QPrintEngine::PPK_PaperSources);
1288
1289 const QList<QVariant> variant_list = v.toList();
1290 QList<QPrinter::PaperSource> int_list;
1291 int_list.reserve(variant_list.size());
1292 for (const auto &variant : variant_list)
1293 int_list << QPrinter::PaperSource(variant.toInt());
1294
1295 return int_list;
1296}
1297
1298#endif // Q_OS_WIN
1299
1300/*!
1301 \fn QString QPrinter::printerSelectionOption() const
1302
1303 Returns the printer options selection string. This is useful only
1304 if the print command has been explicitly set.
1305
1306 The default value (an empty string) implies that the printer should
1307 be selected in a system-dependent manner.
1308
1309 Any other value implies that the given value should be used.
1310
1311 This function always returns an empty string on Windows and Mac.
1312
1313 \sa setPrinterSelectionOption(), setPrintProgram()
1314*/
1315
1316QString QPrinter::printerSelectionOption() const
1317{
1318 Q_D(const QPrinter);
1319 return d->printEngine->property(QPrintEngine::PPK_SelectionOption).toString();
1320}
1321
1322/*!
1323 \fn void QPrinter::setPrinterSelectionOption(const QString &option)
1324
1325 Sets the printer to use \a option to select the printer. \a option
1326 is null by default (which implies that Qt should be smart enough
1327 to guess correctly), but it can be set to other values to use a
1328 specific printer selection option.
1329
1330 If the printer selection option is changed while the printer is
1331 active, the current print job may or may not be affected.
1332
1333 This function has no effect on Windows or Mac.
1334
1335 \sa printerSelectionOption(), setPrintProgram()
1336*/
1337
1338void QPrinter::setPrinterSelectionOption(const QString &option)
1339{
1340 Q_D(QPrinter);
1341 d->setProperty(QPrintEngine::PPK_SelectionOption, option);
1342}
1343
1344/*!
1345 \since 4.1
1346 \fn int QPrinter::fromPage() const
1347
1348 Returns the number of the first page in a range of pages to be printed
1349 (the "from page" setting). Pages in a document are numbered according to
1350 the convention that the first page is page 1.
1351
1352 By default, this function returns a special value of 0, meaning that
1353 the "from page" setting is unset.
1354
1355 \note If fromPage() and toPage() both return 0, this indicates that
1356 \e{the whole document will be printed}.
1357
1358 \sa setFromTo(), toPage(), pageRanges()
1359*/
1360
1361int QPrinter::fromPage() const
1362{
1363 return d->pageRanges.firstPage();
1364}
1365
1366/*!
1367 \since 4.1
1368
1369 Returns the number of the last page in a range of pages to be printed
1370 (the "to page" setting). Pages in a document are numbered according to
1371 the convention that the first page is page 1.
1372
1373 By default, this function returns a special value of 0, meaning that
1374 the "to page" setting is unset.
1375
1376 \note If fromPage() and toPage() both return 0, this indicates that
1377 \e{the whole document will be printed}.
1378
1379 The programmer is responsible for reading this setting and
1380 printing accordingly.
1381
1382 \sa setFromTo(), fromPage(), pageRanges()
1383*/
1384
1385int QPrinter::toPage() const
1386{
1387 return d->pageRanges.lastPage();
1388}
1389
1390/*!
1391 \since 4.1
1392
1393 Sets the range of pages to be printed to cover the pages with numbers
1394 specified by \a from and \a to, where \a from corresponds to the first
1395 page in the range and \a to corresponds to the last.
1396
1397 \note Pages in a document are numbered according to the convention that
1398 the first page is page 1. However, if \a from and \a to are both set to 0,
1399 the \e{whole document will be printed}.
1400
1401 This function is mostly used to set a default value that the user can
1402 override in the print dialog when you call setup().
1403
1404 \sa fromPage(), toPage(), pageRanges()
1405*/
1406
1407void QPrinter::setFromTo(int from, int to)
1408{
1409 d->pageRanges.clear();
1410 if (from && to)
1411 d->pageRanges.addRange(from, to);
1412}
1413
1414/*!
1415 \since 4.1
1416
1417 Sets the print range option in to be \a range.
1418*/
1419void QPrinter::setPrintRange( PrintRange range )
1420{
1421 d->printSelectionOnly = (range == Selection);
1422
1423 Q_D(QPrinter);
1424 d->printRange = range;
1425}
1426
1427/*!
1428 \since 4.1
1429
1430 Returns the page range of the QPrinter. After the print setup
1431 dialog has been opened, this function returns the value selected
1432 by the user.
1433
1434 \sa setPrintRange()
1435*/
1436QPrinter::PrintRange QPrinter::printRange() const
1437{
1438 Q_D(const QPrinter);
1439 return d->printRange;
1440}
1441
1442
1443/*!
1444 \class QPrintEngine
1445 \reentrant
1446
1447 \ingroup printing
1448 \inmodule QtPrintSupport
1449
1450 \brief The QPrintEngine class defines an interface for how QPrinter
1451 interacts with a given printing subsystem.
1452
1453 The common case when creating your own print engine is to derive from both
1454 QPaintEngine and QPrintEngine. Various properties of a print engine are
1455 given with property() and set with setProperty().
1456
1457 \sa QPaintEngine
1458*/
1459
1460/*!
1461 \enum QPrintEngine::PrintEnginePropertyKey
1462
1463 This enum is used to communicate properties between the print
1464 engine and QPrinter. A property may or may not be supported by a
1465 given print engine.
1466
1467 \value PPK_CollateCopies A boolean value indicating whether the
1468 printout should be collated or not.
1469
1470 \value PPK_ColorMode Refers to QPrinter::ColorMode, either color or
1471 monochrome.
1472
1473 \value PPK_Creator A string describing the document's creator.
1474
1475 \value PPK_Duplex A boolean value indicating whether both sides of
1476 the printer paper should be used for the printout.
1477
1478 \value PPK_DocumentName A string describing the document name in
1479 the spooler.
1480
1481 \value PPK_FontEmbedding A boolean value indicating whether data for
1482 the document's fonts should be embedded in the data sent to the
1483 printer.
1484
1485 \value PPK_FullPage A boolean describing if the printer should be
1486 full page or not.
1487
1488 \value PPK_NumberOfCopies Obsolete. An integer specifying the number of
1489 copies. Use PPK_CopyCount instead.
1490
1491 \value PPK_Orientation Specifies a QPageLayout::Orientation value.
1492
1493 \value PPK_OutputFileName The output file name as a string. An
1494 empty file name indicates that the printer should not print to a file.
1495
1496 \value PPK_PageOrder Specifies a QPrinter::PageOrder value.
1497
1498 \value PPK_PageRect A QRect specifying the page rectangle
1499
1500 \value PPK_PageSize Obsolete. Use PPK_PaperSize instead.
1501
1502 \value PPK_PaperRect A QRect specifying the paper rectangle.
1503
1504 \value PPK_PaperSource Specifies a QPrinter::PaperSource value.
1505
1506 \value PPK_PaperSources Specifies more than one QPrinter::PaperSource value.
1507
1508 \value PPK_PaperName A string specifying the name of the paper.
1509
1510 \value PPK_PaperSize Specifies a QPrinter::PaperSize value.
1511
1512 \value PPK_PrinterName A string specifying the name of the printer.
1513
1514 \value PPK_PrinterProgram A string specifying the name of the
1515 printer program used for printing,
1516
1517 \value PPK_Resolution An integer describing the dots per inch for
1518 this printer.
1519
1520 \value PPK_SelectionOption
1521
1522 \value PPK_SupportedResolutions A list of integer QVariants
1523 describing the set of supported resolutions that the printer has.
1524
1525 \value PPK_WindowsPageSize An integer specifying a DM_PAPER entry
1526 on Windows.
1527
1528 \value PPK_CustomPaperSize A QSizeF specifying a custom paper size
1529 in the QPrinter::Point unit.
1530
1531 \value PPK_PageMargins A QList<QVariant> containing the left, top,
1532 right and bottom margin values in the QPrinter::Point unit.
1533
1534 \value PPK_CopyCount An integer specifying the number of copies to print.
1535
1536 \value PPK_SupportsMultipleCopies A boolean value indicating whether or not
1537 the printer supports printing multiple copies in one job.
1538
1539 \value PPK_QPageSize Set the page size using a QPageSize object.
1540
1541 \value PPK_QPageMargins Set the page margins using a std::pair of QMarginsF and QPageLayout::Unit.
1542
1543 \value PPK_QPageLayout Set the page layout using a QPageLayout object.
1544
1545 \value PPK_CustomBase Basis for extension.
1546*/
1547
1548/*!
1549 \fn QPrintEngine::~QPrintEngine()
1550
1551 Destroys the print engine.
1552*/
1553
1554/*!
1555 \fn void QPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &value)
1556
1557 Sets the print engine's property specified by \a key to the given \a value.
1558
1559 \sa property()
1560*/
1561
1562/*!
1563 \fn void QPrintEngine::property(PrintEnginePropertyKey key) const
1564
1565 Returns the print engine's property specified by \a key.
1566
1567 \sa setProperty()
1568*/
1569
1570/*!
1571 \fn bool QPrintEngine::newPage()
1572
1573 Instructs the print engine to start a new page. Returns \c true if
1574 the printer was able to create the new page; otherwise returns \c false.
1575*/
1576
1577/*!
1578 \fn bool QPrintEngine::abort()
1579
1580 Instructs the print engine to abort the printing process. Returns
1581 true if successful; otherwise returns \c false.
1582*/
1583
1584/*!
1585 \fn int QPrintEngine::metric(QPaintDevice::PaintDeviceMetric id) const
1586
1587 Returns the metric for the given \a id.
1588*/
1589
1590/*!
1591 \fn QPrinter::PrinterState QPrintEngine::printerState() const
1592
1593 Returns the current state of the printer being used by the print engine.
1594*/
1595
1596#undef ABORT_IF_ACTIVE
1597
1598QT_END_NAMESPACE
1599
1600#endif // QT_NO_PRINTER
bool setPageLayout(const QPageLayout &newPageLayout) override
Definition qprinter.cpp:162
bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units) override
Definition qprinter.cpp:205
QPageLayout pageLayout() const override
Definition qprinter.cpp:216
QPrinterPagedPaintDevicePrivate(QPrinter *p)
Definition qprinter.cpp:155
bool setPageOrientation(QPageLayout::Orientation orientation) override
Definition qprinter.cpp:195
bool setPageSize(const QPageSize &pageSize) override
Definition qprinter.cpp:178
Combined button and popup list for selecting options.
#define qApp
QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits)
#define ABORT_IF_ACTIVE(location)
Definition qprinter.cpp:31