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.h
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#ifndef QPRINTER_H
6#define QPRINTER_H
7
8#include <QtPrintSupport/qtprintsupportglobal.h>
9#include <QtCore/qstring.h>
10#include <QtCore/qscopedpointer.h>
11#include <QtGui/qpagedpaintdevice.h>
12
14
15
16#ifndef QT_NO_PRINTER
17
18#if defined(B0)
19#undef B0 // Terminal hang-up. We assume that you do not want that.
20#endif
21
22class QPrinterPrivate;
23class QPaintEngine;
24class QPrintEngine;
25class QPrinterInfo;
26class QPageSize;
27
28class Q_PRINTSUPPORT_EXPORT QPrinter : public QPagedPaintDevice
29{
30 Q_DECLARE_PRIVATE(QPrinter)
31public:
32 enum PrinterMode { ScreenResolution, PrinterResolution, HighResolution };
33
34 explicit QPrinter(PrinterMode mode = ScreenResolution);
35 explicit QPrinter(const QPrinterInfo& printer, PrinterMode mode = ScreenResolution);
36 ~QPrinter();
37
38 int devType() const override;
39
40 enum PageOrder { FirstPageFirst,
41 LastPageFirst };
42
43 enum ColorMode { GrayScale,
44 Color };
45
46 enum PaperSource { OnlyOne,
47 Lower,
48 Middle,
49 Manual,
50 Envelope,
51 EnvelopeManual,
52 Auto,
53 Tractor,
54 SmallFormat,
55 LargeFormat,
56 LargeCapacity,
57 Cassette,
58 FormSource,
59 MaxPageSource, // Deprecated
60 CustomSource,
61 LastPaperSource = CustomSource,
62 Upper = OnlyOne // As defined in Windows
63 };
64
65 enum PrinterState { Idle,
66 Active,
67 Aborted,
68 Error };
69
70 enum OutputFormat { NativeFormat, PdfFormat };
71
72 // Keep in sync with QAbstractPrintDialog::PrintRange
73 enum PrintRange { AllPages, Selection, PageRange, CurrentPage };
74
75 enum Unit {
76 Millimeter,
77 Point,
78 Inch,
79 Pica,
80 Didot,
81 Cicero,
82 DevicePixel
83 };
84
85 enum DuplexMode {
86 DuplexNone = 0,
87 DuplexAuto,
88 DuplexLongSide,
89 DuplexShortSide
90 };
91
92 void setOutputFormat(OutputFormat format);
93 OutputFormat outputFormat() const;
94
95 void setPdfVersion(PdfVersion version);
96 PdfVersion pdfVersion() const;
97
98 void setPrinterName(const QString &);
99 QString printerName() const;
100
101 bool isValid() const;
102
103 void setOutputFileName(const QString &);
104 QString outputFileName()const;
105
106 void setPrintProgram(const QString &);
107 QString printProgram() const;
108
109 void setDocName(const QString &);
110 QString docName() const;
111
112 void setCreator(const QString &);
113 QString creator() const;
114
115 void setPageOrder(PageOrder);
116 PageOrder pageOrder() const;
117
118 void setResolution(int);
119 int resolution() const;
120
121 void setColorMode(ColorMode);
122 ColorMode colorMode() const;
123
124 void setCollateCopies(bool collate);
125 bool collateCopies() const;
126
127 void setFullPage(bool);
128 bool fullPage() const;
129
130 void setCopyCount(int);
131 int copyCount() const;
132 bool supportsMultipleCopies() const;
133
134 void setPaperSource(PaperSource);
135 PaperSource paperSource() const;
136
137 void setDuplex(DuplexMode duplex);
138 DuplexMode duplex() const;
139
140 QList<int> supportedResolutions() const;
141
142#if defined(Q_OS_WIN) || defined(Q_QDOC)
143 QList<PaperSource> supportedPaperSources() const;
144#endif
145
146 void setFontEmbeddingEnabled(bool enable);
147 bool fontEmbeddingEnabled() const;
148
149 QRectF paperRect(Unit) const;
150 QRectF pageRect(Unit) const;
151
152 QString printerSelectionOption() const;
153 void setPrinterSelectionOption(const QString &);
154
155 bool newPage() override;
156 bool abort();
157
158 PrinterState printerState() const;
159
160 QPaintEngine *paintEngine() const override;
161 QPrintEngine *printEngine() const;
162
163 void setFromTo(int fromPage, int toPage);
164 int fromPage() const;
165 int toPage() const;
166
167 void setPrintRange(PrintRange range);
168 PrintRange printRange() const;
169
170protected:
171 int metric(PaintDeviceMetric) const override;
172 void setEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine);
173
174private:
175 Q_DISABLE_COPY(QPrinter)
176
177 QScopedPointer<QPrinterPrivate> d_ptr;
178
179 friend class QPrintDialogPrivate;
180 friend class QAbstractPrintDialog;
181 friend class QAbstractPrintDialogPrivate;
182 friend class QPrintPreviewWidgetPrivate;
183 friend class QTextDocument;
184 friend class QPageSetupWidget;
185};
186
187#endif // QT_NO_PRINTER
188
189QT_END_NAMESPACE
190
191#endif // QPRINTER_H
QPointer< QObject > receiverToDisconnectOnClose
void setPrinter(QPrinter *newPrinter)
virtual void setTabs(const QList< QWidget * > &)
friend class QPaintEngine
Definition qpainter.h:437
The QPrintDialog class provides a dialog for specifying the printer's configuration.
\reentrant
Definition qprinter.h:29
QT_REQUIRE_CONFIG(printdialog)
QT_REQUIRE_CONFIG(animation)