Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#include "qprinter.h"
5#include "qprinter_p.h"
6
7#ifndef QT_NO_PRINTER
8
9#include <qpa/qplatformprintplugin.h>
10#include <qpa/qplatformprintersupport.h>
11
12#include "qprintengine.h"
13#include "qlist.h"
14#include <qcoreapplication.h>
15#include <qfileinfo.h>
16
17#include <private/qpagedpaintdevice_p.h>
18
19#include "qprintengine_pdf_p.h"
20
21#include <qpicture.h>
22#if QT_CONFIG(printpreviewwidget)
23#include <private/qpaintengine_preview_p.h>
24#endif
25
27
28using namespace Qt::StringLiterals;
29
30#define ABORT_IF_ACTIVE(location) \
31 if (d->printEngine->printerState() == QPrinter::Active) { \
32 qWarning("%s: Cannot be changed while printer is active", location); \
33 return; \
34 }
35
36#define ABORT_IF_ACTIVE_RETURN(location, retValue) \
37 if (d->printEngine->printerState() == QPrinter::Active) { \
38 qWarning("%s: Cannot be changed while printer is active", location); \
39 return retValue; \
40 }
41
42extern qreal qt_pixelMultiplier(int resolution);
43extern QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits);
44
46{
47 // Try find a valid printer to use, either the one given, the default or the first available
48 QPrinterInfo printerToUse = printer;
49 if (printerToUse.isNull()) {
50 printerToUse = QPrinterInfo::defaultPrinter();
51 if (printerToUse.isNull()) {
52 QStringList availablePrinterNames = QPrinterInfo::availablePrinterNames();
53 if (!availablePrinterNames.isEmpty())
54 printerToUse = QPrinterInfo::printerInfo(availablePrinterNames.at(0));
55 }
56 }
57 return printerToUse;
58}
59
61{
62 // Default to PdfFormat
64 QPlatformPrinterSupport *ps = nullptr;
65 QString printerName;
66
67 // Only set NativeFormat if we have a valid plugin and printer to use
70 QPrinterInfo printerToUse = findValidPrinter(printer);
71 if (ps && !printerToUse.isNull()) {
73 printerName = printerToUse.printerName();
74 }
75 }
76
80 } else {
81 static const QHash<QPrinter::PdfVersion, QPdfEngine::PdfVersion> engineMapping {
85 };
86 const auto pdfEngineVersion = engineMapping.value(pdfVersion, QPdfEngine::Version_1_4);
87 QPdfPrintEngine *pdfEngine = new QPdfPrintEngine(printerMode, pdfEngineVersion);
88 paintEngine = pdfEngine;
89 printEngine = pdfEngine;
90 }
91
92 use_default_engine = true;
94 validPrinter = true;
95}
96
98{
99 QPrintEngine *oldPrintEngine = printEngine;
100 const bool def_engine = use_default_engine;
101
102 initEngines(format, printer);
103
104 if (oldPrintEngine) {
105 const auto properties = m_properties; // take a copy: setProperty() below modifies m_properties
106 for (const auto &key : properties) {
107 QVariant prop;
108 // PPK_NumberOfCopies need special treatmeant since it in most cases
109 // will return 1, disregarding the actual value that was set
110 // PPK_PrinterName also needs special treatment as initEngines has set it already
112 prop = QVariant(q_ptr->copyCount());
114 prop = oldPrintEngine->property(key);
115 if (prop.isValid())
116 setProperty(key, prop);
117 }
118 }
119
120 if (def_engine)
121 delete oldPrintEngine;
122}
123
124#if QT_CONFIG(printpreviewwidget)
125QList<const QPicture *> QPrinterPrivate::previewPages() const
126{
127 if (previewEngine)
128 return previewEngine->pages();
129 return QList<const QPicture *>();
130}
131
132bool QPrinterPrivate::previewMode() const
133{
134 return (previewEngine != nullptr) && (previewEngine == printEngine);
135}
136
137void QPrinterPrivate::setPreviewMode(bool enable)
138{
139 Q_Q(QPrinter);
140 if (enable) {
141 if (!previewEngine)
142 previewEngine = new QPreviewPaintEngine;
144 use_default_engine = false;
147 q->setEngines(previewEngine, previewEngine);
148 previewEngine->setProxyEngines(realPrintEngine, realPaintEngine);
149 } else {
150 q->setEngines(realPrintEngine, realPaintEngine);
152 }
153}
154#endif // QT_CONFIG(printpreviewwidget)
155
161
162
164{
165public:
169
172
173 bool setPageLayout(const QPageLayout &newPageLayout) override
174 {
176
179 qWarning("QPrinter::setPageLayout: Cannot be changed while printer is active");
180 return false;
181 }
182
183 // Try to set the print engine page layout
185
186 return pageLayout().isEquivalentTo(newPageLayout);
187 }
188
189 bool setPageSize(const QPageSize &pageSize) override
190 {
192
195 qWarning("QPrinter::setPageLayout: Cannot be changed while printer is active");
196 return false;
197 }
198
199
200 // Try to set the print engine page size
202
203 return pageLayout().pageSize().isEquivalentTo(pageSize);
204 }
205
207 {
209
210 // Set the print engine value
212
213 return pageLayout().orientation() == orientation;
214 }
215
216 bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units) override
217 {
219
220 // Try to set print engine margins
221 QPair<QMarginsF, QPageLayout::Unit> pair = qMakePair(margins, units);
223
224 return pageLayout().margins() == margins && pageLayout().units() == units;
225 }
226
227 QPageLayout pageLayout() const override
228 {
230
231 return qvariant_cast<QPageLayout>(pd->printEngine->property(QPrintEngine::PPK_QPageLayout));
232 }
233
235};
236
237
452
460 d_ptr(new QPrinterPrivate(this))
461{
462 d_ptr->init(printer, mode);
463}
464
466{
468 qFatal("QPrinter: Must construct a QCoreApplication before a QPrinter");
469 return;
470 }
471
473
475}
476
492void QPrinter::setEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine)
493{
494 Q_D(QPrinter);
495
496 if (d->use_default_engine)
497 delete d->printEngine;
498
499 d->printEngine = printEngine;
500 d->paintEngine = paintEngine;
501 d->use_default_engine = false;
502}
503
510{
511 Q_D(QPrinter);
512 if (d->use_default_engine)
513 delete d->printEngine;
514#if QT_CONFIG(printpreviewwidget)
515 delete d->previewEngine;
516#endif
517}
518
550{
551 Q_D(QPrinter);
552
553 if (d->outputFormat == format)
554 return;
555
557 QPrinterInfo printerToUse = d->findValidPrinter();
558 if (!printerToUse.isNull())
559 d->changeEngines(format, printerToUse);
560 } else {
561 d->changeEngines(format, QPrinterInfo());
562 }
563}
564
571{
572 Q_D(const QPrinter);
573 return d->outputFormat;
574}
575
584{
585 Q_D(QPrinter);
586
587 if (d->pdfVersion == version)
588 return;
589
590 d->pdfVersion = version;
591
592 if (d->outputFormat == QPrinter::PdfFormat) {
593 d->changeEngines(d->outputFormat, QPrinterInfo());
594 }
595}
596
603{
604 Q_D(const QPrinter);
605 return d->pdfVersion;
606}
607
611{
612 return QInternal::Printer;
613}
614
622{
623 Q_D(const QPrinter);
624 return d->printEngine->property(QPrintEngine::PPK_PrinterName).toString();
625}
626
639{
640 Q_D(QPrinter);
641 ABORT_IF_ACTIVE("QPrinter::setPrinterName");
642
643 if (printerName() == name)
644 return;
645
646 if (name.isEmpty()) {
648 return;
649 }
650
652 if (printerToUse.isNull())
653 return;
654
656 d->changeEngines(QPrinter::NativeFormat, printerToUse);
657 } else {
658 d->setProperty(QPrintEngine::PPK_PrinterName, name);
659 }
660}
661
675{
676 Q_D(const QPrinter);
677 if (!qApp)
678 return false;
679 return d->validPrinter;
680}
681
693{
694 Q_D(const QPrinter);
695 return d->printEngine->property(QPrintEngine::PPK_OutputFileName).toString();
696}
697
718{
719 Q_D(QPrinter);
720 ABORT_IF_ACTIVE("QPrinter::setOutputFileName");
721
723 if (!fi.suffix().compare("pdf"_L1, Qt::CaseInsensitive))
725 else if (fileName.isEmpty())
727
729}
730
731
744{
745 Q_D(const QPrinter);
746 return d->printEngine->property(QPrintEngine::PPK_PrinterProgram).toString();
747}
748
749
759void QPrinter::setPrintProgram(const QString &printProg)
760{
761 Q_D(QPrinter);
762 ABORT_IF_ACTIVE("QPrinter::setPrintProgram");
763 d->setProperty(QPrintEngine::PPK_PrinterProgram, printProg);
764}
765
766
773{
774 Q_D(const QPrinter);
775 return d->printEngine->property(QPrintEngine::PPK_DocumentName).toString();
776}
777
778
790{
791 Q_D(QPrinter);
792 ABORT_IF_ACTIVE("QPrinter::setDocName");
794}
795
796
803{
804 Q_D(const QPrinter);
805 return d->printEngine->property(QPrintEngine::PPK_Creator).toString();
806}
807
808
820{
821 Q_D(QPrinter);
822 ABORT_IF_ACTIVE("QPrinter::setCreator");
823 d->setProperty(QPrintEngine::PPK_Creator, creator);
824}
825
840{
842
843 Q_D(QPrinter);
844 ABORT_IF_ACTIVE("QPrinter::setPageOrder");
846}
847
848
856{
857 Q_D(const QPrinter);
858 return QPrinter::PageOrder(d->printEngine->property(QPrintEngine::PPK_PageOrder).toInt());
859}
860
861
870{
871 Q_D(QPrinter);
872 ABORT_IF_ACTIVE("QPrinter::setColorMode");
873 d->setProperty(QPrintEngine::PPK_ColorMode, newColorMode);
874}
875
876
883{
884 Q_D(const QPrinter);
885 return QPrinter::ColorMode(d->printEngine->property(QPrintEngine::PPK_ColorMode).toInt());
886}
887
900{
901 Q_D(QPrinter);
902 ABORT_IF_ACTIVE("QPrinter::setCopyCount;");
903 d->setProperty(QPrintEngine::PPK_CopyCount, count);
904}
905
915{
916 Q_D(const QPrinter);
917 return d->printEngine->property(QPrintEngine::PPK_CopyCount).toInt();
918}
919
935{
936 Q_D(const QPrinter);
937 return d->printEngine->property(QPrintEngine::PPK_SupportsMultipleCopies).toBool();
938}
939
952{
953 Q_D(const QPrinter);
954 return d->printEngine->property(QPrintEngine::PPK_CollateCopies).toBool();
955}
956
957
969{
970 Q_D(QPrinter);
971 ABORT_IF_ACTIVE("QPrinter::setCollateCopies");
972 d->setProperty(QPrintEngine::PPK_CollateCopies, collate);
973}
974
975
976
999{
1000 Q_D(QPrinter);
1001 // Set the print engine
1002 d->setProperty(QPrintEngine::PPK_FullPage, fp);
1003}
1004
1005
1017{
1018 Q_D(const QPrinter);
1019 return d->printEngine->property(QPrintEngine::PPK_FullPage).toBool();
1020}
1021
1022
1037{
1038 Q_D(QPrinter);
1039 ABORT_IF_ACTIVE("QPrinter::setResolution");
1040 d->setProperty(QPrintEngine::PPK_Resolution, dpi);
1041}
1042
1043
1052{
1053 Q_D(const QPrinter);
1054 return d->printEngine->property(QPrintEngine::PPK_Resolution).toInt();
1055}
1056
1071
1077{
1078 Q_D(const QPrinter);
1079 return QPrinter::PaperSource(d->printEngine->property(QPrintEngine::PPK_PaperSource).toInt());
1080}
1081
1082
1091{
1092 Q_D(QPrinter);
1094}
1095
1104{
1105 Q_D(const QPrinter);
1106 return d->printEngine->property(QPrintEngine::PPK_FontEmbedding).toBool();
1107}
1108
1135{
1136 Q_D(QPrinter);
1137 d->setProperty(QPrintEngine::PPK_Duplex, duplex);
1138}
1139
1148{
1149 Q_D(const QPrinter);
1150 return static_cast <DuplexMode> (d->printEngine->property(QPrintEngine::PPK_Duplex).toInt());
1151}
1152
1163{
1164 if (unit == QPrinter::DevicePixel)
1166 else
1167 return pageLayout().paintRect(QPageLayout::Unit(unit));
1168}
1169
1170
1180{
1181 if (unit == QPrinter::DevicePixel)
1183 else
1184 return pageLayout().fullRect(QPageLayout::Unit(unit));
1185}
1186
1193{
1194 Q_D(const QPrinter);
1195 return d->printEngine->metric(id);
1196}
1197
1202{
1203 Q_D(const QPrinter);
1204 return d->paintEngine;
1205}
1206
1213{
1214 Q_D(const QPrinter);
1215 return d->printEngine;
1216}
1217
1227{
1228 Q_D(const QPrinter);
1229 const QList<QVariant> varlist
1230 = d->printEngine->property(QPrintEngine::PPK_SupportedResolutions).toList();
1231 QList<int> intlist;
1232 intlist.reserve(varlist.size());
1233 for (const auto &var : varlist)
1234 intlist << var.toInt();
1235 return intlist;
1236}
1237
1247{
1248 Q_D(QPrinter);
1249 if (d->printEngine->printerState() != QPrinter::Active)
1250 return false;
1251 return d->printEngine->newPage();
1252}
1253
1264{
1265 Q_D(QPrinter);
1266 return d->printEngine->abort();
1267}
1268
1275{
1276 Q_D(const QPrinter);
1277 return d->printEngine->printerState();
1278}
1279
1280#if defined(Q_OS_WIN) || defined(Q_QDOC)
1292QList<QPrinter::PaperSource> QPrinter::supportedPaperSources() const
1293{
1294 Q_D(const QPrinter);
1295 QVariant v = d->printEngine->property(QPrintEngine::PPK_PaperSources);
1296
1297 const QList<QVariant> variant_list = v.toList();
1298 QList<QPrinter::PaperSource> int_list;
1299 int_list.reserve(variant_list.size());
1300 for (const auto &variant : variant_list)
1301 int_list << QPrinter::PaperSource(variant.toInt());
1302
1303 return int_list;
1304}
1305
1306#endif // Q_OS_WIN
1307
1325{
1326 Q_D(const QPrinter);
1327 return d->printEngine->property(QPrintEngine::PPK_SelectionOption).toString();
1328}
1329
1351
1370{
1371 return d->pageRanges.firstPage();
1372}
1373
1394{
1395 return d->pageRanges.lastPage();
1396}
1397
1415void QPrinter::setFromTo(int from, int to)
1416{
1417 d->pageRanges.clear();
1418 if (from && to)
1419 d->pageRanges.addRange(from, to);
1420}
1421
1428{
1430
1431 Q_D(QPrinter);
1432 d->printRange = range;
1433}
1434
1445{
1446 Q_D(const QPrinter);
1447 return d->printRange;
1448}
1449
1450
1605
1606#endif // QT_NO_PRINTER
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
\inmodule QtCore
Definition qmargins.h:270
\inmodule QtGui
Definition qpagelayout.h:20
QRectF fullRect() const
Returns the full page rectangle in the current layout units.
bool isEquivalentTo(const QPageLayout &other) const
Returns true if this page layout is equivalent to the other page layout, i.e.
Unit units() const
Returns the units the page layout is currently defined in.
QRectF paintRect() const
Returns the page rectangle in the current layout units.
Unit
This enum type is used to specify the measurement unit for page layout and margins.
Definition qpagelayout.h:24
QMarginsF margins() const
Returns the margins of the page layout using the currently set units.
Orientation orientation() const
Returns the page orientation of the page layout.
QRect paintRectPixels(int resolution) const
Returns the paintable rectangle in rounded device pixels for the given resolution.
Orientation
This enum type defines the page orientation.
Definition qpagelayout.h:33
QRect fullRectPixels(int resolution) const
Returns the full page rectangle in device pixels for the given resolution.
QPageSize pageSize() const
Returns the page size of the page layout.
void clear()
Removes all page ranges.
int lastPage() const
Returns the index of the last page covered by the page ranges, or 0 if the page ranges are empty.
int firstPage() const
Returns the index of the first page covered by the page ranges, or 0 if the page ranges are empty.
void addRange(int from, int to)
Adds the range specified with from and to to the ranges.
\inmodule QtGui
Definition qpagesize.h:22
bool isEquivalentTo(const QPageSize &other) const
Returns true if this page is equivalent to the other page, i.e.
\inmodule QtGui
QPageLayout pageLayout() const
QPagedPaintDevicePrivate * d
PdfVersion
The PdfVersion enum describes the version of the PDF file that is produced by QPrinter or QPdfWriter.
\inmodule QtGui
virtual Type type() const =0
Reimplement this function to return the paint engine \l{Type}.
@ Version_1_4
Definition qpdf_p.h:135
@ Version_A1b
Definition qpdf_p.h:136
@ Version_1_6
Definition qpdf_p.h:137
static QPlatformPrinterSupport * get()
The QPlatformPrinterSupport class provides an abstraction for print support.
virtual QPrintEngine * createNativePrintEngine(QPrinter::PrinterMode printerMode, const QString &deviceId=QString())
virtual QPaintEngine * createPaintEngine(QPrintEngine *, QPrinter::PrinterMode printerMode)
\reentrant
virtual QPrinter::PrinterState printerState() const =0
Returns the current state of the printer being used by the print engine.
virtual void setProperty(PrintEnginePropertyKey key, const QVariant &value)=0
Sets the print engine's property specified by key to the given value.
virtual QVariant property(PrintEnginePropertyKey key) const =0
Returns the print engine's property specified by key.
PrintEnginePropertyKey
This enum is used to communicate properties between the print engine and QPrinter.
@ PPK_SupportedResolutions
@ PPK_SupportsMultipleCopies
The QPrinterInfo class gives access to information about existing printers.
static QStringList availablePrinterNames()
Returns a list of all the available Printer Names on this system.
static QPrinterInfo defaultPrinter()
Returns the default printer on the system.
static QPrinterInfo printerInfo(const QString &printerName)
Returns the printer printerName.
bool setPageLayout(const QPageLayout &newPageLayout) override
Definition qprinter.cpp:173
bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units) override
Definition qprinter.cpp:216
QPageLayout pageLayout() const override
Definition qprinter.cpp:227
QPrinterPagedPaintDevicePrivate(QPrinter *p)
Definition qprinter.cpp:166
bool setPageOrientation(QPageLayout::Orientation orientation) override
Definition qprinter.cpp:206
bool setPageSize(const QPageSize &pageSize) override
Definition qprinter.cpp:189
uint use_default_engine
Definition qprinter_p.h:94
QPrinter * q_ptr
Definition qprinter_p.h:90
QPrinterInfo findValidPrinter(const QPrinterInfo &printer=QPrinterInfo())
Definition qprinter.cpp:45
QPrinter::PdfVersion pdfVersion
Definition qprinter_p.h:80
void initEngines(QPrinter::OutputFormat format, const QPrinterInfo &printer)
Definition qprinter.cpp:60
QPrinter::OutputFormat outputFormat
Definition qprinter_p.h:79
uint had_default_engines
Definition qprinter_p.h:95
QPrinter::PrinterMode printerMode
Definition qprinter_p.h:78
QSet< QPrintEngine::PrintEnginePropertyKey > m_properties
Definition qprinter_p.h:101
QPrintEngine * printEngine
Definition qprinter_p.h:81
void init(const QPrinterInfo &printer, QPrinter::PrinterMode mode)
Definition qprinter.cpp:465
QPaintEngine * realPaintEngine
Definition qprinter_p.h:85
QPaintEngine * paintEngine
Definition qprinter_p.h:82
void changeEngines(QPrinter::OutputFormat format, const QPrinterInfo &printer)
Definition qprinter.cpp:97
QPrintEngine * realPrintEngine
Definition qprinter_p.h:84
void setProperty(QPrintEngine::PrintEnginePropertyKey key, const QVariant &value)
Definition qprinter.cpp:156
static QPrinterPrivate * get(QPrinter *printer)
Definition qprinter_p.h:61
\reentrant
Definition qprinter.h:28
QRectF paperRect(Unit) const
bool supportsMultipleCopies() const
Definition qprinter.cpp:934
void setFontEmbeddingEnabled(bool enable)
PdfVersion pdfVersion() const
Definition qprinter.cpp:602
QString creator() const
Returns the name of the application that created the document.
Definition qprinter.cpp:802
QPrintEngine * printEngine() const
DuplexMode duplex() const
void setPrintRange(PrintRange range)
int metric(PaintDeviceMetric) const override
QRectF pageRect(Unit) const
bool fontEmbeddingEnabled() const
bool newPage() override
Tells the printer to eject the current page and to continue printing on a new page.
void setPrinterSelectionOption(const QString &)
Sets the printer to use option to select the printer.
PaperSource
This enum type specifies what paper source QPrinter is to use.
Definition qprinter.h:45
void setEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine)
This function is used by subclasses of QPrinter to specify custom print and paint engines (printEngin...
Definition qprinter.cpp:492
@ DevicePixel
Definition qprinter.h:81
void setPrintProgram(const QString &)
Sets the name of the program that should do the print job to printProg.
Definition qprinter.cpp:759
void setPaperSource(PaperSource)
Sets the paper source setting to source.
void setCollateCopies(bool collate)
Definition qprinter.cpp:968
QString printProgram() const
Returns the name of the program that sends the print output to the printer.
Definition qprinter.cpp:743
int toPage() const
void setPdfVersion(PdfVersion version)
Definition qprinter.cpp:583
ColorMode colorMode() const
Returns the current color mode.
Definition qprinter.cpp:882
OutputFormat
The OutputFormat enum is used to describe the format QPrinter should use for printing.
Definition qprinter.h:69
@ NativeFormat
Definition qprinter.h:69
@ PdfFormat
Definition qprinter.h:69
int devType() const override
Definition qprinter.cpp:610
QPaintEngine * paintEngine() const override
Returns the paint engine used by the printer.
void setOutputFormat(OutputFormat format)
Definition qprinter.cpp:549
ColorMode
This enum type is used to indicate whether QPrinter should print in color or not.
Definition qprinter.h:42
bool isValid() const
Definition qprinter.cpp:674
QList< int > supportedResolutions() const
Returns a list of the resolutions (a list of dots-per-inch integers) that the printer says it support...
QString docName() const
Returns the document name.
Definition qprinter.cpp:772
int resolution() const
Returns the current assumed resolution of the printer, as set by setResolution() or by the printer dr...
void setDuplex(DuplexMode duplex)
void setFullPage(bool)
If fp is true, enables support for painting over the entire page; otherwise restricts painting to the...
Definition qprinter.cpp:998
void setColorMode(ColorMode)
Sets the printer's color mode to newColorMode, which can be either Color or GrayScale.
Definition qprinter.cpp:869
PaperSource paperSource() const
Returns the printer's paper source.
QString outputFileName() const
Returns the name of the output file.
Definition qprinter.cpp:692
void setFromTo(int fromPage, int toPage)
PrinterMode
This enum describes the mode the printer should work in.
Definition qprinter.h:31
PrintRange printRange() const
int fromPage() const
bool abort()
Aborts the current print run.
void setOutputFileName(const QString &)
Sets the name of the output file to fileName.
Definition qprinter.cpp:717
bool fullPage() const
Returns true if the origin of the printer's coordinate system is at the corner of the page and false ...
PrinterState
\value Idle \value Active \value Aborted \value Error
Definition qprinter.h:64
PrinterState printerState() const
Returns the current state of the printer.
QPrinter(PrinterMode mode=ScreenResolution)
Creates a new printer object with the given mode.
Definition qprinter.cpp:446
QString printerName() const
Returns the printer name.
Definition qprinter.cpp:621
void setDocName(const QString &)
Sets the document name to name.
Definition qprinter.cpp:789
void setCreator(const QString &)
Sets the name of the application that created the document to creator.
Definition qprinter.cpp:819
PageOrder
This enum type is used by QPrinter to tell the application program how to print.
Definition qprinter.h:39
@ FirstPageFirst
Definition qprinter.h:39
void setPageOrder(PageOrder)
Sets the page order to pageOrder.
Definition qprinter.cpp:839
PrintRange
Used to specify the print range selection option.
Definition qprinter.h:72
@ Selection
Definition qprinter.h:72
QString printerSelectionOption() const
Returns the printer options selection string.
int copyCount() const
Definition qprinter.cpp:914
OutputFormat outputFormat() const
Definition qprinter.cpp:570
bool collateCopies() const
Definition qprinter.cpp:951
void setPrinterName(const QString &)
Sets the printer name to name.
Definition qprinter.cpp:638
void setResolution(int)
Requests that the printer prints at dpi or as near to dpi as possible.
~QPrinter()
Destroys the printer object and frees any allocated resources.
Definition qprinter.cpp:509
PageOrder pageOrder() const
Returns the current page order.
Definition qprinter.cpp:855
void setCopyCount(int)
Definition qprinter.cpp:899
\inmodule QtCore\reentrant
Definition qrect.h:484
iterator insert(const T &value)
Definition qset.h:155
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qvariant.h:65
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
Definition qvariant.h:714
int toInt(bool *ok=nullptr) const
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool,...
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Definition qvariant.h:536
#define this
Definition dialogs.cpp:9
Combined button and popup list for selecting options.
@ CaseInsensitive
#define Q_UNLIKELY(x)
#define qApp
static const QCssKnownValue properties[NumProperties - 1]
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define qWarning
Definition qlogging.h:166
#define qFatal
Definition qlogging.h:168
GLsizei const GLfloat * v
[13]
GLenum mode
GLuint64 key
GLenum GLenum GLsizei count
GLsizei range
GLboolean enable
GLfloat units
GLuint name
GLint GLsizei GLsizei GLenum format
GLsizei GLsizei GLchar * source
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLfloat GLfloat p
[1]
GLuint GLenum option
QT_BEGIN_NAMESPACE constexpr decltype(auto) qMakePair(T1 &&value1, T2 &&value2) noexcept(noexcept(std::make_pair(std::forward< T1 >(value1), std::forward< T2 >(value2))))
Definition qpair.h:19
QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits)
#define ABORT_IF_ACTIVE(location)
Definition qprinter.cpp:30
qreal qt_pixelMultiplier(int resolution)
#define fp
double qreal
Definition qtypes.h:187
static int toInt(const QChar &qc, int R)
QVariant variant
[1]
QItemEditorCreatorBase * creator
args<< 1<< 2;QJSValue threeAgain=fun.call(args);QString fileName="helloworld.qs";QFile scriptFile(fileName);if(!scriptFile.open(QIODevice::ReadOnly)) QTextStream stream(&scriptFile);QString contents=stream.readAll();scriptFile.close();myEngine.evaluate(contents, fileName);myEngine.globalObject().setProperty("myNumber", 123);...QJSValue myNumberPlusOne=myEngine.evaluate("myNumber + 1");QJSValue result=myEngine.evaluate(...);if(result.isError()) qDebug()<< "Uncaught exception at line"<< result.property("lineNumber").toInt()<< ":"<< result.toString();QPushButton *button=new QPushButton;QJSValue scriptButton=myEngine.newQObject(button);myEngine.globalObject().setProperty("button", scriptButton);myEngine.evaluate("button.checkable = true");qDebug()<< scriptButton.property("checkable").toBool();scriptButton.property("show").call();QJSEngine engine;QObject *myQObject=new QObject();myQObject- setProperty)("dynamicProperty", 3)