Qt 4.8
qprinter.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/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 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qprinter_p.h"
43 #include "qprinter.h"
44 #include "qprintengine.h"
45 #include "qprinterinfo.h"
46 #include "qlist.h"
47 #include <qpagesetupdialog.h>
48 #include <qapplication.h>
49 #include <qfileinfo.h>
50 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
51 #include "private/qcups_p.h"
52 #endif
53 
54 #ifndef QT_NO_PRINTER
55 
56 #if defined (Q_WS_WIN)
57 #include <private/qprintengine_win_p.h>
58 #elif defined (Q_WS_MAC)
59 #include <private/qprintengine_mac_p.h>
60 #elif defined (QTOPIA_PRINTENGINE)
61 #include <private/qprintengine_qws_p.h>
62 #endif
63 #include <private/qprintengine_ps_p.h>
64 
65 #if defined(Q_WS_X11)
66 #include <private/qt_x11_p.h>
67 #endif
68 
69 #ifndef QT_NO_PDF
70 #include "qprintengine_pdf_p.h"
71 #endif
72 
73 #include <qpicture.h>
74 #include <private/qpaintengine_preview_p.h>
75 
76 #if defined(QT3_SUPPORT)
77 # include "qprintdialog.h"
78 #endif // QT3_SUPPORT
79 
81 
82 #define ABORT_IF_ACTIVE(location) \
83  if (d->printEngine->printerState() == QPrinter::Active) { \
84  qWarning("%s: Cannot be changed while printer is active", location); \
85  return; \
86  }
87 
88 // NB! This table needs to be in sync with QPrinter::PaperSize
89 static const float qt_paperSizes[][2] = {
90  {210, 297}, // A4
91  {176, 250}, // B5
92  {215.9f, 279.4f}, // Letter
93  {215.9f, 355.6f}, // Legal
94  {190.5f, 254}, // Executive
95  {841, 1189}, // A0
96  {594, 841}, // A1
97  {420, 594}, // A2
98  {297, 420}, // A3
99  {148, 210}, // A5
100  {105, 148}, // A6
101  {74, 105}, // A7
102  {52, 74}, // A8
103  {37, 52}, // A8
104  {1000, 1414}, // B0
105  {707, 1000}, // B1
106  {31, 44}, // B10
107  {500, 707}, // B2
108  {353, 500}, // B3
109  {250, 353}, // B4
110  {125, 176}, // B6
111  {88, 125}, // B7
112  {62, 88}, // B8
113  {33, 62}, // B9
114  {163, 229}, // C5E
115  {105, 241}, // US Common
116  {110, 220}, // DLE
117  {210, 330}, // Folio
118  {431.8f, 279.4f}, // Ledger
119  {279.4f, 431.8f} // Tabloid
120 };
121 
123 double qt_multiplierForUnit(QPrinter::Unit unit, int resolution)
124 {
125  switch(unit) {
127  return 2.83464566929;
128  case QPrinter::Point:
129  return 1.0;
130  case QPrinter::Inch:
131  return 72.0;
132  case QPrinter::Pica:
133  return 12;
134  case QPrinter::Didot:
135  return 1.065826771;
136  case QPrinter::Cicero:
137  return 12.789921252;
139  return 72.0/resolution;
140  }
141  return 1.0;
142 }
143 
144 // not static: it's needed in qpagesetupdialog_unix.cpp
147  QPrinter::Unit unit,
148  int resolution)
149 {
150  int width_index = 0;
151  int height_index = 1;
152  if (orientation == QPrinter::Landscape) {
153  width_index = 1;
154  height_index = 0;
155  }
156  const qreal multiplier = qt_multiplierForUnit(unit, resolution);
157  return QSizeF((qt_paperSizes[paperSize][width_index] * 72 / 25.4) / multiplier,
158  (qt_paperSizes[paperSize][height_index] * 72 / 25.4) / multiplier);
159 }
160 
162 {
163  QPrinter::OutputFormat realOutputFormat = outputFormat;
164 #if !defined (QTOPIA_PRINTENGINE)
165 #if defined (Q_OS_UNIX) && ! defined (Q_WS_MAC)
167  realOutputFormat = QPrinter::PostScriptFormat;
168  }
169 #endif
170 #endif
171 
172  switch (realOutputFormat) {
173  case QPrinter::NativeFormat: {
174 #if defined (Q_WS_WIN)
176  paintEngine = winEngine;
177  printEngine = winEngine;
178 #elif defined (Q_WS_MAC)
179  QMacPrintEngine *macEngine = new QMacPrintEngine(printerMode);
180  paintEngine = macEngine;
181  printEngine = macEngine;
182 #elif defined (QTOPIA_PRINTENGINE)
184  paintEngine = qwsEngine;
185  printEngine = qwsEngine;
186 #elif defined (Q_OS_UNIX)
187  Q_ASSERT(false);
188 #endif
189  }
190  break;
191  case QPrinter::PdfFormat: {
192  QPdfEngine *pdfEngine = new QPdfEngine(printerMode);
193  paintEngine = pdfEngine;
194  printEngine = pdfEngine;
195  }
196  break;
198  QPSPrintEngine *psEngine = new QPSPrintEngine(printerMode);
199  paintEngine = psEngine;
200  printEngine = psEngine;
201  }
202  break;
203  }
204  use_default_engine = true;
205  had_default_engines = true;
206 }
207 
208 #ifndef QT_NO_PRINTPREVIEWWIDGET
210 {
211  if (previewEngine)
212  return previewEngine->pages();
213  return QList<const QPicture *>();
214 }
215 
217 {
218  Q_Q(QPrinter);
219  if (enable) {
220  if (!previewEngine)
223  use_default_engine = false;
226  q->setEngines(previewEngine, previewEngine);
228  } else {
229  q->setEngines(realPrintEngine, realPaintEngine);
231  }
232 }
233 #endif // QT_NO_PRINTPREVIEWWIDGET
234 
236 {
237  for (int c = 0; c < manualSetList.size(); ++c) {
238  if (manualSetList[c] == key) return;
239  }
240  manualSetList.append(key);
241 }
242 
243 
599 /*
600  \enum QPrinter::PrintRange
601 
602  This enum is used to specify which print range the application
603  should use to print.
604 
605  \value AllPages All the pages should be printed.
606  \value Selection Only the selection should be printed.
607  \value PageRange Print according to the from page and to page options.
608  \value CurrentPage Only the current page should be printed.
609 
610  \sa setPrintRange(), printRange()
611 */
612 
613 /*
614  \enum QPrinter::PrinterOption
615 
616  This enum describes various printer options that appear in the
617  printer setup dialog. It is used to enable and disable these
618  options in the setup dialog.
619 
620  \value PrintToFile Describes if print to file should be enabled.
621  \value PrintSelection Describes if printing selections should be enabled.
622  \value PrintPageRange Describes if printing page ranges (from, to) should
623  be enabled
624  \value PrintCurrentPage if Print Current Page option should be enabled
625 
626  \sa setOptionEnabled(), isOptionEnabled()
627 */
628 
633  : QPaintDevice(),
634  d_ptr(new QPrinterPrivate(this))
635 {
636  init(mode);
638  if (!defPrn.isNull()) {
639  setPrinterName(defPrn.printerName());
640  } else if (QPrinterInfo::availablePrinters().isEmpty()
644  }
645 }
646 
656  : QPaintDevice(),
657  d_ptr(new QPrinterPrivate(this))
658 {
659  init(mode);
660  setPrinterName(printer.printerName());
661 }
662 
664 {
665 #if !defined(Q_WS_X11)
666  if (!qApp) {
667 #else
668  if (!qApp || !X11) {
669 #endif
670  qFatal("QPrinter: Must construct a QApplication before a QPaintDevice");
671  return;
672  }
673  Q_D(QPrinter);
674 
675  d->printerMode = mode;
676  d->outputFormat = QPrinter::NativeFormat;
677  d->createDefaultEngines();
678 
679 #ifndef QT_NO_PRINTPREVIEWWIDGET
680  d->previewEngine = 0;
681 #endif
682  d->realPrintEngine = 0;
683  d->realPaintEngine = 0;
684 
685 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
686  if (QCUPSSupport::cupsVersion() >= 10200 && QCUPSSupport().currentPPD()) {
688  d->outputFormat = QPrinter::NativeFormat;
689  }
690 #endif
691 }
692 
709 {
710  Q_D(QPrinter);
711 
712  if (d->use_default_engine)
713  delete d->printEngine;
714 
715  d->printEngine = printEngine;
716  d->paintEngine = paintEngine;
717  d->use_default_engine = false;
718 }
719 
726 {
727  Q_D(QPrinter);
728  if (d->use_default_engine)
729  delete d->printEngine;
730 #ifndef QT_NO_PRINTPREVIEWWIDGET
731  delete d->previewEngine;
732 #endif
733 }
734 
766 {
767 
768 #ifndef QT_NO_PDF
769  Q_D(QPrinter);
770  if (d->validPrinter && d->outputFormat == format)
771  return;
772  d->outputFormat = format;
773 
774  QPrintEngine *oldPrintEngine = d->printEngine;
775  const bool def_engine = d->use_default_engine;
776  d->printEngine = 0;
777 
778  d->createDefaultEngines();
779 
780  if (oldPrintEngine) {
781  for (int i = 0; i < d->manualSetList.size(); ++i) {
782  QPrintEngine::PrintEnginePropertyKey key = d->manualSetList[i];
783  QVariant prop;
784  // PPK_NumberOfCopies need special treatmeant since it in most cases
785  // will return 1, disregarding the actual value that was set
787  prop = QVariant(copyCount());
788  else
789  prop = oldPrintEngine->property(key);
790  if (prop.isValid())
791  d->printEngine->setProperty(key, prop);
792  }
793  }
794 
795  if (def_engine)
796  delete oldPrintEngine;
797 
798  if (d->outputFormat == QPrinter::PdfFormat || d->outputFormat == QPrinter::PostScriptFormat)
799  d->validPrinter = true;
800 #else
801  Q_UNUSED(format);
802 #endif
803 }
804 
814 {
815  Q_D(const QPrinter);
816  return d->outputFormat;
817 }
818 
819 
820 
823 int QPrinter::devType() const
824 {
825  return QInternal::Printer;
826 }
827 
835 {
836  Q_D(const QPrinter);
837  return d->printEngine->property(QPrintEngine::PPK_PrinterName).toString();
838 }
839 
846 {
847  Q_D(QPrinter);
848  ABORT_IF_ACTIVE("QPrinter::setPrinterName");
849 
850 #if defined(Q_OS_UNIX) && !defined(QT_NO_CUPS)
851  if(d->use_default_engine
852  && d->outputFormat == QPrinter::NativeFormat) {
853  if (QCUPSSupport::cupsVersion() >= 10200
856  else
858  d->outputFormat = QPrinter::NativeFormat;
859  }
860 #endif
861 
863  if (name.isEmpty()) {
864  d->validPrinter = d->outputFormat == QPrinter::PdfFormat || d->outputFormat == QPrinter::PostScriptFormat;
865  } else {
866  d->validPrinter = false;
867  for (int i = 0; i < prnList.size(); ++i) {
868  if (prnList[i].printerName() == name) {
869  d->validPrinter = true;
870  break;
871  }
872  }
873  }
874 
875  d->printEngine->setProperty(QPrintEngine::PPK_PrinterName, name);
876  d->addToManualSetList(QPrintEngine::PPK_PrinterName);
877 }
878 
879 
895 bool QPrinter::isValid() const
896 {
897  Q_D(const QPrinter);
898 #if defined(Q_WS_X11)
899  if (!qApp || !X11) {
900  return false;
901  }
902 #endif
903  return d->validPrinter;
904 }
905 
906 
951 {
952  Q_D(const QPrinter);
953  return d->printEngine->property(QPrintEngine::PPK_OutputFileName).toString();
954 }
955 
977 {
978  Q_D(QPrinter);
979  ABORT_IF_ACTIVE("QPrinter::setOutputFileName");
980 
981  QFileInfo fi(fileName);
984  else if (!fi.suffix().compare(QLatin1String("pdf"), Qt::CaseInsensitive))
986  else if (fileName.isEmpty())
988 
989  d->printEngine->setProperty(QPrintEngine::PPK_OutputFileName, fileName);
990  d->addToManualSetList(QPrintEngine::PPK_OutputFileName);
991 }
992 
993 
1006 {
1007  Q_D(const QPrinter);
1008  return d->printEngine->property(QPrintEngine::PPK_PrinterProgram).toString();
1009 }
1010 
1011 
1021 void QPrinter::setPrintProgram(const QString &printProg)
1022 {
1023  Q_D(QPrinter);
1024  ABORT_IF_ACTIVE("QPrinter::setPrintProgram");
1025  d->printEngine->setProperty(QPrintEngine::PPK_PrinterProgram, printProg);
1026  d->addToManualSetList(QPrintEngine::PPK_PrinterProgram);
1027 }
1028 
1029 
1036 {
1037  Q_D(const QPrinter);
1038  return d->printEngine->property(QPrintEngine::PPK_DocumentName).toString();
1039 }
1040 
1041 
1053 {
1054  Q_D(QPrinter);
1055  ABORT_IF_ACTIVE("QPrinter::setDocName");
1056  d->printEngine->setProperty(QPrintEngine::PPK_DocumentName, name);
1057  d->addToManualSetList(QPrintEngine::PPK_DocumentName);
1058 }
1059 
1060 
1067 {
1068  Q_D(const QPrinter);
1069  return d->printEngine->property(QPrintEngine::PPK_Creator).toString();
1070 }
1071 
1072 
1084 {
1085  Q_D(QPrinter);
1086  ABORT_IF_ACTIVE("QPrinter::setCreator");
1087  d->printEngine->setProperty(QPrintEngine::PPK_Creator, creator);
1088  d->addToManualSetList(QPrintEngine::PPK_Creator);
1089 }
1090 
1091 
1099 {
1100  Q_D(const QPrinter);
1101  return QPrinter::Orientation(d->printEngine->property(QPrintEngine::PPK_Orientation).toInt());
1102 }
1103 
1104 
1123 {
1124  Q_D(QPrinter);
1125  d->printEngine->setProperty(QPrintEngine::PPK_Orientation, orientation);
1126  d->addToManualSetList(QPrintEngine::PPK_Orientation);
1127 }
1128 
1129 
1141 {
1142  Q_D(const QPrinter);
1143  return QPrinter::PaperSize(d->printEngine->property(QPrintEngine::PPK_PaperSize).toInt());
1144 }
1145 
1164 {
1165  Q_D(QPrinter);
1166  if (d->paintEngine->type() != QPaintEngine::Pdf)
1167  ABORT_IF_ACTIVE("QPrinter::setPaperSize");
1168  if (newPaperSize < 0 || newPaperSize >= NPaperSize) {
1169  qWarning("QPrinter::setPaperSize: Illegal paper size %d", newPaperSize);
1170  return;
1171  }
1172  d->printEngine->setProperty(QPrintEngine::PPK_PaperSize, newPaperSize);
1173  d->addToManualSetList(QPrintEngine::PPK_PaperSize);
1174  d->hasUserSetPageSize = true;
1175 }
1176 
1188 {
1189  return paperSize();
1190 }
1191 
1192 
1205 {
1206  setPaperSize(newPageSize);
1207 }
1208 
1221 {
1222  Q_D(QPrinter);
1223  if (d->paintEngine->type() != QPaintEngine::Pdf)
1224  ABORT_IF_ACTIVE("QPrinter::setPaperSize");
1225  const qreal multiplier = qt_multiplierForUnit(unit, resolution());
1226  QSizeF size(paperSize.width() * multiplier, paperSize.height() * multiplier);
1227  d->printEngine->setProperty(QPrintEngine::PPK_CustomPaperSize, size);
1228  d->addToManualSetList(QPrintEngine::PPK_CustomPaperSize);
1229  d->hasUserSetPageSize = true;
1230 }
1231 
1244 {
1245  Q_D(const QPrinter);
1246  int res = resolution();
1247  const qreal multiplier = qt_multiplierForUnit(unit, res);
1248  PaperSize paperType = paperSize();
1249  if (paperType == Custom) {
1250  QSizeF size = d->printEngine->property(QPrintEngine::PPK_CustomPaperSize).toSizeF();
1251  return QSizeF(size.width() / multiplier, size.height() / multiplier);
1252  }
1253  else {
1254  return qt_printerPaperSize(orientation(), paperType, unit, res);
1255  }
1256 }
1257 
1272 {
1273  Q_D(QPrinter);
1274  ABORT_IF_ACTIVE("QPrinter::setPageOrder");
1275  d->printEngine->setProperty(QPrintEngine::PPK_PageOrder, pageOrder);
1276  d->addToManualSetList(QPrintEngine::PPK_PageOrder);
1277 }
1278 
1279 
1287 {
1288  Q_D(const QPrinter);
1289  return QPrinter::PageOrder(d->printEngine->property(QPrintEngine::PPK_PageOrder).toInt());
1290 }
1291 
1292 
1301 {
1302  Q_D(QPrinter);
1303  ABORT_IF_ACTIVE("QPrinter::setColorMode");
1304  d->printEngine->setProperty(QPrintEngine::PPK_ColorMode, newColorMode);
1305  d->addToManualSetList(QPrintEngine::PPK_ColorMode);
1306 }
1307 
1308 
1315 {
1316  Q_D(const QPrinter);
1317  return QPrinter::ColorMode(d->printEngine->property(QPrintEngine::PPK_ColorMode).toInt());
1318 }
1319 
1320 
1344 {
1345  Q_D(const QPrinter);
1346  return d->printEngine->property(QPrintEngine::PPK_NumberOfCopies).toInt();
1347 }
1348 
1349 
1368 {
1369  return copyCount();
1370 }
1371 
1372 
1373 
1390 {
1391  Q_D(QPrinter);
1392  ABORT_IF_ACTIVE("QPrinter::setNumCopies");
1393  d->printEngine->setProperty(QPrintEngine::PPK_NumberOfCopies, numCopies);
1394  d->addToManualSetList(QPrintEngine::PPK_NumberOfCopies);
1395 }
1396 
1411 void QPrinter::setCopyCount(int count)
1412 {
1413  Q_D(QPrinter);
1414  ABORT_IF_ACTIVE("QPrinter::setCopyCount;");
1415  d->printEngine->setProperty(QPrintEngine::PPK_CopyCount, count);
1416  d->addToManualSetList(QPrintEngine::PPK_CopyCount);
1417 }
1418 
1431 {
1432  Q_D(const QPrinter);
1433  return d->printEngine->property(QPrintEngine::PPK_CopyCount).toInt();
1434 }
1435 
1454 {
1455  Q_D(const QPrinter);
1456  return d->printEngine->property(QPrintEngine::PPK_SupportsMultipleCopies).toBool();
1457 }
1458 
1474 {
1475  Q_D(const QPrinter);
1476  return d->printEngine->property(QPrintEngine::PPK_CollateCopies).toBool();
1477 }
1478 
1479 
1493 void QPrinter::setCollateCopies(bool collate)
1494 {
1495  Q_D(QPrinter);
1496  ABORT_IF_ACTIVE("QPrinter::setCollateCopies");
1497  d->printEngine->setProperty(QPrintEngine::PPK_CollateCopies, collate);
1498  d->addToManualSetList(QPrintEngine::PPK_CollateCopies);
1499 }
1500 
1501 
1502 
1525 {
1526  Q_D(QPrinter);
1527  d->printEngine->setProperty(QPrintEngine::PPK_FullPage, fp);
1528  d->addToManualSetList(QPrintEngine::PPK_FullPage);
1529 }
1530 
1531 
1543 {
1544  Q_D(const QPrinter);
1545  return d->printEngine->property(QPrintEngine::PPK_FullPage).toBool();
1546 }
1547 
1548 
1563 {
1564  Q_D(QPrinter);
1565  ABORT_IF_ACTIVE("QPrinter::setResolution");
1566  d->printEngine->setProperty(QPrintEngine::PPK_Resolution, dpi);
1567  d->addToManualSetList(QPrintEngine::PPK_Resolution);
1568 }
1569 
1570 
1579 {
1580  Q_D(const QPrinter);
1581  return d->printEngine->property(QPrintEngine::PPK_Resolution).toInt();
1582 }
1583 
1594 {
1595  Q_D(QPrinter);
1596  d->printEngine->setProperty(QPrintEngine::PPK_PaperSource, source);
1597  d->addToManualSetList(QPrintEngine::PPK_PaperSource);
1598 }
1599 
1605 {
1606  Q_D(const QPrinter);
1607  return QPrinter::PaperSource(d->printEngine->property(QPrintEngine::PPK_PaperSource).toInt());
1608 }
1609 
1610 
1624 {
1625  Q_D(QPrinter);
1626  d->printEngine->setProperty(QPrintEngine::PPK_FontEmbedding, enable);
1627  d->addToManualSetList(QPrintEngine::PPK_FontEmbedding);
1628 }
1629 
1643 {
1644  Q_D(const QPrinter);
1645  return d->printEngine->property(QPrintEngine::PPK_FontEmbedding).toBool();
1646 }
1647 
1679 void QPrinter::setDoubleSidedPrinting(bool doubleSided)
1680 {
1681  setDuplex(doubleSided ? DuplexAuto : DuplexNone);
1682 }
1683 
1684 
1696 {
1697  return duplex() != DuplexNone;
1698 }
1699 
1711 {
1712  Q_D(QPrinter);
1713  d->printEngine->setProperty(QPrintEngine::PPK_Duplex, duplex);
1714  d->addToManualSetList(QPrintEngine::PPK_Duplex);
1715 }
1716 
1728 {
1729  Q_D(const QPrinter);
1730  return static_cast <DuplexMode> (d->printEngine->property(QPrintEngine::PPK_Duplex).toInt());
1731 }
1732 
1746 {
1747  Q_D(const QPrinter);
1748  int res = resolution();
1749  const qreal multiplier = qt_multiplierForUnit(unit, res);
1750  // the page rect is in device pixels
1751  QRect devRect(d->printEngine->property(QPrintEngine::PPK_PageRect).toRect());
1752  if (unit == DevicePixel)
1753  return devRect;
1754  QRectF diRect(devRect.x()*72.0/res,
1755  devRect.y()*72.0/res,
1756  devRect.width()*72.0/res,
1757  devRect.height()*72.0/res);
1758  return QRectF(diRect.x()/multiplier, diRect.y()/multiplier,
1759  diRect.width()/multiplier, diRect.height()/multiplier);
1760 }
1761 
1762 
1775 {
1776  Q_D(const QPrinter);
1777  int res = resolution();
1778  const qreal multiplier = qt_multiplierForUnit(unit, resolution());
1779  // the page rect is in device pixels
1780  QRect devRect(d->printEngine->property(QPrintEngine::PPK_PaperRect).toRect());
1781  if (unit == DevicePixel)
1782  return devRect;
1783  QRectF diRect(devRect.x()*72.0/res,
1784  devRect.y()*72.0/res,
1785  devRect.width()*72.0/res,
1786  devRect.height()*72.0/res);
1787  return QRectF(diRect.x()/multiplier, diRect.y()/multiplier,
1788  diRect.width()/multiplier, diRect.height()/multiplier);
1789 }
1790 
1801 {
1802  Q_D(const QPrinter);
1803  return d->printEngine->property(QPrintEngine::PPK_PageRect).toRect();
1804 }
1805 
1815 {
1816  Q_D(const QPrinter);
1817  return d->printEngine->property(QPrintEngine::PPK_PaperRect).toRect();
1818 }
1819 
1820 
1832 {
1833  Q_D(QPrinter);
1834  const qreal multiplier = qt_multiplierForUnit(unit, resolution());
1835  QList<QVariant> margins;
1836  margins << (left * multiplier) << (top * multiplier)
1837  << (right * multiplier) << (bottom * multiplier);
1838  d->printEngine->setProperty(QPrintEngine::PPK_PageMargins, margins);
1839  d->addToManualSetList(QPrintEngine::PPK_PageMargins);
1840  d->hasCustomPageMargins = true;
1841 }
1842 
1854 {
1855  Q_D(const QPrinter);
1856  Q_ASSERT(left && top && right && bottom);
1857  const qreal multiplier = qt_multiplierForUnit(unit, resolution());
1858  QList<QVariant> margins(d->printEngine->property(QPrintEngine::PPK_PageMargins).toList());
1859  *left = margins.at(0).toReal() / multiplier;
1860  *top = margins.at(1).toReal() / multiplier;
1861  *right = margins.at(2).toReal() / multiplier;
1862  *bottom = margins.at(3).toReal() / multiplier;
1863 }
1864 
1874 {
1875  Q_D(const QPrinter);
1876  return d->printEngine->metric(id);
1877 }
1878 
1883 {
1884  Q_D(const QPrinter);
1885  return d->paintEngine;
1886 }
1887 
1897 {
1898  Q_D(const QPrinter);
1899  return d->printEngine;
1900 }
1901 
1902 #if defined (Q_WS_WIN)
1903 
1913 {
1914  Q_D(QPrinter);
1915  ABORT_IF_ACTIVE("QPrinter::setWinPageSize");
1916  d->printEngine->setProperty(QPrintEngine::PPK_WindowsPageSize, pageSize);
1917  d->addToManualSetList(QPrintEngine::PPK_WindowsPageSize);
1918 }
1919 
1929 {
1930  Q_D(const QPrinter);
1931  return d->printEngine->property(QPrintEngine::PPK_WindowsPageSize).toInt();
1932 }
1933 #endif // Q_WS_WIN
1934 
1944 {
1945  Q_D(const QPrinter);
1946  QList<QVariant> varlist
1947  = d->printEngine->property(QPrintEngine::PPK_SupportedResolutions).toList();
1948  QList<int> intlist;
1949  for (int i=0; i<varlist.size(); ++i)
1950  intlist << varlist.at(i).toInt();
1951  return intlist;
1952 }
1953 
1963 {
1964  Q_D(QPrinter);
1965  if (d->printEngine->printerState() != QPrinter::Active)
1966  return false;
1967  return d->printEngine->newPage();
1968 }
1969 
1980 {
1981  Q_D(QPrinter);
1982  return d->printEngine->abort();
1983 }
1984 
1991 {
1992  Q_D(const QPrinter);
1993  return d->printEngine->printerState();
1994 }
1995 
1996 
2050 #ifdef Q_WS_WIN
2051 
2054 HDC QPrinter::getDC() const
2055 {
2056  Q_D(const QPrinter);
2057  return d->printEngine->getPrinterDC();
2058 }
2059 
2063 void QPrinter::releaseDC(HDC hdc) const
2064 {
2065  Q_D(const QPrinter);
2066  d->printEngine->releasePrinterDC(hdc);
2067 }
2068 
2081 {
2082  Q_D(const QPrinter);
2083  QVariant v = d->printEngine->property(QPrintEngine::PPK_PaperSources);
2084 
2085  QList<QVariant> variant_list = v.toList();
2087  for (int i=0; i<variant_list.size(); ++i)
2088  int_list << (QPrinter::PaperSource) variant_list.at(i).toInt();
2089 
2090  return int_list;
2091 }
2092 
2093 #endif
2094 
2133 #ifndef Q_WS_WIN
2135 {
2136  Q_D(const QPrinter);
2137  return d->printEngine->property(QPrintEngine::PPK_SelectionOption).toString();
2138 }
2139 
2140 void QPrinter::setPrinterSelectionOption(const QString &option)
2141 {
2142  Q_D(QPrinter);
2143  d->printEngine->setProperty(QPrintEngine::PPK_SelectionOption, option);
2144  d->addToManualSetList(QPrintEngine::PPK_SelectionOption);
2145 }
2146 #endif
2147 
2169 {
2170  Q_D(const QPrinter);
2171  return d->fromPage;
2172 }
2173 
2196 int QPrinter::toPage() const
2197 {
2198  Q_D(const QPrinter);
2199  return d->toPage;
2200 }
2201 
2222 void QPrinter::setFromTo(int from, int to)
2223 {
2224  Q_D(QPrinter);
2225  if (from > to) {
2226  qWarning() << "QPrinter::setFromTo: 'from' must be less than or equal to 'to'";
2227  from = to;
2228  }
2229  d->fromPage = from;
2230  d->toPage = to;
2231 
2232  if (d->minPage == 0 && d->maxPage == 0) {
2233  d->minPage = 1;
2234  d->maxPage = to;
2236  }
2237 }
2238 
2248 {
2249  Q_D(QPrinter);
2250  d->printRange = QAbstractPrintDialog::PrintRange(range);
2251 }
2252 
2266 {
2267  Q_D(const QPrinter);
2268  return PrintRange(d->printRange);
2269 }
2270 
2271 #if defined(QT3_SUPPORT)
2272 
2273 void QPrinter::setOutputToFile(bool f)
2274 {
2275  if (f) {
2276  if (outputFileName().isEmpty())
2277  setOutputFileName(QLatin1String("untitled_printer_document"));
2278  } else {
2280  }
2281 }
2282 
2283 bool qt_compat_QPrinter_printSetup(QPrinter *printer, QPrinterPrivate *pd, QWidget *parent)
2284 {
2285  Q_UNUSED(pd);
2286  QPrintDialog dlg(printer, parent);
2287  return dlg.exec() != 0;
2288 }
2289 
2290 
2291 #ifdef Q_WS_MAC
2292 bool qt_compat_QPrinter_pageSetup(QPrinter *p, QWidget *parent)
2293 {
2294  QPageSetupDialog psd(p, parent);
2295  return psd.exec() != 0;
2296 }
2297 
2303 bool QPrinter::pageSetup(QWidget *parent)
2304 {
2305  return qt_compat_QPrinter_pageSetup(this, parent);
2306 }
2307 
2313 bool QPrinter::printSetup(QWidget *parent)
2314 {
2315  Q_D(QPrinter);
2316  return qt_compat_QPrinter_printSetup(this, d, parent);
2317 }
2318 #endif // Q_WS_MAC
2319 
2332 bool QPrinter::setup(QWidget *parent)
2333 {
2334  Q_D(QPrinter);
2335  return qt_compat_QPrinter_printSetup(this, d, parent)
2336 #ifdef Q_WS_MAC
2337  && qt_compat_QPrinter_pageSetup(this, parent);
2338 #endif
2339  ;
2340 }
2341 
2345 int QPrinter::minPage() const
2346 {
2347  Q_D(const QPrinter);
2348  return d->minPage;
2349 }
2350 
2354 int QPrinter::maxPage() const
2355 {
2356  Q_D(const QPrinter);
2357  return d->maxPage;
2358 }
2359 
2363 void QPrinter::setMinMax( int minPage, int maxPage )
2364 {
2365  Q_D(QPrinter);
2366  Q_ASSERT_X(minPage <= maxPage, "QPrinter::setMinMax",
2367  "'min' must be less than or equal to 'max'");
2368  d->minPage = minPage;
2369  d->maxPage = maxPage;
2370  d->options |= QPrintDialog::PrintPageRange;
2371 }
2372 
2382 bool QPrinter::collateCopiesEnabled() const
2383 {
2384  Q_D(const QPrinter);
2385  return (d->options & QPrintDialog::PrintCollateCopies);
2386 }
2387 
2394 void QPrinter::setCollateCopiesEnabled(bool enable)
2395 {
2396  Q_D(QPrinter);
2397 
2398  if (enable)
2399  d->options |= QPrintDialog::PrintCollateCopies;
2400  else
2401  d->options &= ~QPrintDialog::PrintCollateCopies;
2402 }
2403 
2407 void QPrinter::setOptionEnabled( PrinterOption option, bool enable )
2408 {
2409  Q_D(QPrinter);
2410  if (enable)
2411  d->options |= QPrintDialog::PrintDialogOption(1 << option);
2412  else
2413  d->options &= ~QPrintDialog::PrintDialogOption(1 << option);
2414 }
2415 
2419 bool QPrinter::isOptionEnabled( PrinterOption option ) const
2420 {
2421  Q_D(const QPrinter);
2422  return (d->options & QPrintDialog::PrintDialogOption(option));
2423 }
2424 
2425 #endif // QT3_SUPPORT
2426 
2612 /*
2613  Returns the dimensions for the given paper size, \a size, in millimeters.
2614 */
2616 {
2617  if (size == QPrinter::Custom) return QSizeF(0, 0);
2618  return QSizeF(qt_paperSizes[size][0], qt_paperSizes[size][1]);
2619 }
2620 
2621 /*
2622  Returns the PaperSize type that matches \a size, where \a size
2623  is in millimeters.
2624 
2625  Because dimensions may not always be completely accurate (for
2626  example when converting between units), a particular PaperSize
2627  will be returned if it matches within -1/+1 millimeters.
2628 */
2630 {
2631  for (int i = 0; i < static_cast<int>(QPrinter::NPaperSize); ++i) {
2632  if (qt_paperSizes[i][0] >= size.width() - 1 &&
2633  qt_paperSizes[i][0] <= size.width() + 1 &&
2634  qt_paperSizes[i][1] >= size.height() - 1 &&
2635  qt_paperSizes[i][1] <= size.height() + 1) {
2636  return QPrinter::PaperSize(i);
2637  }
2638  }
2639 
2640  return QPrinter::Custom;
2641 }
2642 
2644 
2645 #endif // QT_NO_PRINTER
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
DuplexMode duplex() const
Returns the current duplex mode.
Definition: qprinter.cpp:1727
void setPageOrder(PageOrder)
Sets the page order to pageOrder.
Definition: qprinter.cpp:1271
QList< const QPicture * > pages()
bool fullPage() const
Returns true if the origin of the printer&#39;s coordinate system is at the corner of the page and false ...
Definition: qprinter.cpp:1542
double d
Definition: qnumeric_p.h:62
void setDuplex(DuplexMode duplex)
Enables double sided printing based on the duplex mode.
Definition: qprinter.cpp:1710
QList< QPrintEngine::PrintEnginePropertyKey > manualSetList
Definition: qprinter_p.h:133
QScopedPointer< QPrinterPrivate > d_ptr
Definition: qprinter.h:298
static QPrinterInfo defaultPrinter()
Returns the default printer on the system.
QString creator() const
Returns the name of the application that created the document.
Definition: qprinter.cpp:1066
PaperSize paperSize(QPrinter::PaperSize paperSize)
Definition: qpdf.cpp:905
int toPage() const
Returns the number of the last page in a range of pages to be printed (the "to page" setting)...
Definition: qprinter.cpp:2196
double qreal
Definition: qglobal.h:1193
QPrintEngine * printEngine
Definition: qprinter_p.h:110
unsigned char c[8]
Definition: qnumeric_p.h:62
PrinterState
Definition: qprinter.h:119
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
PrinterState printerState() const
Returns the current state of the printer.
Definition: qprinter.cpp:1990
QRect pageRect() const
Returns the page&#39;s rectangle; this is usually smaller than the paperRect() since the page normally ha...
Definition: qprinter.cpp:1800
QPrintEngine * realPrintEngine
Definition: qprinter_p.h:113
QString docName() const
Returns the document name.
Definition: qprinter.cpp:1035
void init(PrinterMode mode)
Definition: qprinter.cpp:663
void setWinPageSize(int winPageSize)
Sets the page size to be used by the printer under Windows to pageSize.
Definition: qprinter.cpp:1912
qreal width() const
Returns the width.
Definition: qsize.h:284
PrinterMode
This enum describes the mode the printer should work in.
Definition: qprinter.h:70
int fromPage() const
Returns the number of the first page in a range of pages to be printed (the "from page" setting)...
Definition: qprinter.cpp:2168
QPaintEngine * realPaintEngine
Definition: qprinter_p.h:114
void setFontEmbeddingEnabled(bool enable)
Enabled or disables font embedding depending on enable.
Definition: qprinter.cpp:1623
qreal height() const
Returns the height.
Definition: qsize.h:287
void setPageMargins(qreal left, qreal top, qreal right, qreal bottom, Unit unit)
This function sets the left, top, right and bottom page margins for this printer. ...
Definition: qprinter.cpp:1831
void setProxyEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QPrinter::PaperSize qSizeFTopaperSize(const QSizeF &size)
Definition: qprinter.cpp:2629
Orientation
This enum type (not to be confused with Orientation) is used to specify each page&#39;s orientation...
Definition: qprinter.h:78
double qt_multiplierForUnit(QPrinter::Unit unit, int resolution)
return the multiplier of converting from the unit value to postscript-points.
Definition: qprinter.cpp:123
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:708
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has type() List or StringList ; otherwise return...
Definition: qvariant.cpp:2751
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QString printerSelectionOption() const
Returns the printer options selection string.
void setPaperSize(PaperSize)
Sets the printer paper size to newPaperSize if that size is supported.
Definition: qprinter.cpp:1163
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QString outputFileName() const
Returns the name of the output file.
Definition: qprinter.cpp:950
#define X11
Definition: qt_x11_p.h:724
#define Q_D(Class)
Definition: qglobal.h:2482
void releaseDC(HDC hdc) const
Definition: qprinter.cpp:2063
virtual QVariant property(PrintEnginePropertyKey key) const =0
Returns the print engine&#39;s property specified by key.
bool abort()
Aborts the current print run.
Definition: qprinter.cpp:1979
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
void setPaperSource(PaperSource)
Sets the paper source setting to source.
Definition: qprinter.cpp:1593
void setCollateCopies(bool collate)
Sets the default value for collation checkbox when the print dialog appears.
Definition: qprinter.cpp:1493
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
PageSize pageSize() const
Returns the printer page size.
Definition: qprinter.cpp:1187
void setOrientation(Orientation)
Sets the print orientation to orientation.
Definition: qprinter.cpp:1122
QPrintEngine * printEngine() const
Returns the print engine used by the printer.
Definition: qprinter.cpp:1896
#define Q_Q(Class)
Definition: qglobal.h:2483
void setCopyCount(int)
Sets the number of copies to be printed to count.
Definition: qprinter.cpp:1411
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
Unit
This enum type is used to specify the measurement unit for page and paper sizes.
Definition: qprinter.h:129
QRect paperRect() const
Returns the paper&#39;s rectangle; this is usually larger than the pageRect().
Definition: qprinter.cpp:1814
The QPrintDialog class provides a dialog for specifying the printer&#39;s configuration.
Definition: qprintdialog.h:81
void setPrintProgram(const QString &)
Sets the name of the program that should do the print job to printProg.
Definition: qprinter.cpp:1021
PrintRange
Used to specify the print range selection option.
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
DuplexMode
This enum is used to indicate whether printing will occur on one or both sides of each sheet of paper...
Definition: qprinter.h:139
int winPageSize() const
Returns the page size used by the printer under Windows.
Definition: qprinter.cpp:1928
The QPageSetupDialog class provides a configuration dialog for the page-related options on a printer...
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
OutputFormat outputFormat() const
Returns the output format for this printer.
Definition: qprinter.cpp:813
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
PaperSize paperSize() const
Returns the printer paper size.
Definition: qprinter.cpp:1140
static bool isEmpty(const char *str)
Orientation orientation() const
Returns the orientation setting.
Definition: qprinter.cpp:1098
The QPrintEngine class defines an interface for how QPrinter interacts with a given printing subsyste...
Definition: qprintengine.h:56
void setFullPage(bool)
If fp is true, enables support for painting over the entire page; otherwise restricts painting to the...
Definition: qprinter.cpp:1524
void setPageSize(PageSize)
Sets the printer page size based on newPageSize.
Definition: qprinter.cpp:1204
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define qApp
PrintDialogOption
Used to specify which parts of the print dialog should be visible.
const char * name
The QPrinter class is a paint device that paints on a printer.
Definition: qprinter.h:66
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
virtual Type type() const =0
Reimplement this function to return the paint engine Type.
void setPrintRange(PrintRange range)
Sets the print range option in to be range.
Definition: qprinter.cpp:2247
OutputFormat
The OutputFormat enum is used to describe the format QPrinter should use for printing.
Definition: qprinter.h:124
bool isValid() const
Returns true if the printer currently selected is a valid printer in the system, or a pure PDF/PostSc...
Definition: qprinter.cpp:895
Q_CORE_EXPORT void qWarning(const char *,...)
PaperSource paperSource() const
Returns the printer&#39;s paper source.
Definition: qprinter.cpp:1604
PrintRange printRange() const
Returns the page range of the QPrinter.
Definition: qprinter.cpp:2265
QSizeF qt_paperSizeToQSizeF(QPrinter::PaperSize size)
Definition: qprinter.cpp:2615
void setFromTo(int fromPage, int toPage)
Sets the range of pages to be printed to cover the pages with numbers specified by from and to...
Definition: qprinter.cpp:2222
void setCreator(const QString &)
Sets the name of the application that created the document to creator.
Definition: qprinter.cpp:1083
int exec()
Reimplemented Function
ColorMode colorMode() const
Returns the current color mode.
Definition: qprinter.cpp:1314
void setColorMode(ColorMode)
Sets the printer&#39;s color mode to newColorMode, which can be either Color or GrayScale.
Definition: qprinter.cpp:1300
bool supportsMultipleCopies() const
Returns true if the printer supports printing multiple copies of the same document in one job; otherw...
Definition: qprinter.cpp:1453
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Definition: qpaintengine.h:90
int devType() const
Definition: qprinter.cpp:823
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
QPrinter::PrinterMode printerMode
Definition: qprinter_p.h:108
QList< const QPicture * > previewPages() const
Definition: qprinter.cpp:209
bool fontEmbeddingEnabled() const
Returns true if font embedding is enabled.
Definition: qprinter.cpp:1642
void setNumCopies(int)
Sets the number of copies to be printed to numCopies.
Definition: qprinter.cpp:1389
void addToManualSetList(QPrintEngine::PrintEnginePropertyKey key)
Definition: qprinter.cpp:235
bool newPage()
Tells the printer to eject the current page and to continue printing on a new page.
Definition: qprinter.cpp:1962
int numCopies() const
Returns the number of copies to be printed.
Definition: qprinter.cpp:1343
QSizeF qt_printerPaperSize(QPrinter::Orientation orientation, QPrinter::PaperSize paperSize, QPrinter::Unit unit, int resolution)
Definition: qprinter.cpp:145
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
The QPrinterInfo class gives access to information about existing printers.
Definition: qprinterinfo.h:58
HDC getDC() const
Definition: qprinter.cpp:2054
QString printerName() const
Returns the name of the printer.
Q_CORE_EXPORT void qFatal(const char *,...)
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
void setResolution(int)
Requests that the printer prints at dpi or as near to dpi as possible.
Definition: qprinter.cpp:1562
QPaintEngine * paintEngine() const
Returns the paint engine used by the printer.
Definition: qprinter.cpp:1882
int compare(const QString &s) const
Definition: qstring.cpp:5037
QList< PaperSource > supportedPaperSources() const
Returns the supported paper sizes for this printer.
Definition: qprinter.cpp:2080
bool collateCopies() const
Returns true if collation is turned on when multiple copies is selected.
Definition: qprinter.cpp:1473
int actualNumCopies() const
Returns the number of copies that will be printed.
Definition: qprinter.cpp:1367
PaperSize
This enum type specifies what paper size QPrinter should use.
Definition: qprinter.h:91
QPreviewPaintEngine * previewEngine
Definition: qprinter_p.h:116
uint use_default_engine
Definition: qprinter_p.h:125
QString suffix() const
Returns the suffix of the file.
Definition: qfileinfo.cpp:834
int key
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
int resolution() const
Returns the current assumed resolution of the printer, as set by setResolution() or by the printer dr...
Definition: qprinter.cpp:1578
bool doubleSidedPrinting() const
Returns true if double side printing is enabled.
Definition: qprinter.cpp:1695
ColorMode
This enum type is used to indicate whether QPrinter should print in color or not. ...
Definition: qprinter.h:100
static QList< QPrinterInfo > availablePrinters()
Returns a list of available printers on the system.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
bool isNull() const
Returns whether this QPrinterInfo object holds a printer definition.
PageOrder
This enum type is used by QPrinter to tell the application program how to print.
Definition: qprinter.h:97
QPaintEngine * paintEngine
Definition: qprinter_p.h:111
int copyCount() const
Returns the number of copies that will be printed.
Definition: qprinter.cpp:1430
PrintRange
Used to specify the print range selection option.
Definition: qprinter.h:127
int metric(PaintDeviceMetric) const
Returns the metric for the given id.
Definition: qprinter.cpp:1873
void setPrinterSelectionOption(const QString &)
Sets the printer to use option to select the printer.
void createDefaultEngines()
Definition: qprinter.cpp:161
void setOutputFormat(OutputFormat format)
Sets the output format for this printer to format.
Definition: qprinter.cpp:765
void setDocName(const QString &)
Sets the document name to name.
Definition: qprinter.cpp:1052
PageSize
Use QPrinter::PaperSize instead.
Definition: qprinter.h:87
QList< int > supportedResolutions() const
Returns a list of the resolutions (a list of dots-per-inch integers) that the printer says it support...
Definition: qprinter.cpp:1943
static const float qt_paperSizes[][2]
Definition: qprinter.cpp:89
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
Definition: qvariant.h:485
QString printerName() const
Returns the printer name.
Definition: qprinter.cpp:834
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
static bool printerHasPPD(const char *printerName)
Definition: qcups.cpp:342
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
static QString fileName(const QString &fileUrl)
QPrinter(PrinterMode mode=ScreenResolution)
Creates a new printer object with the given mode.
Definition: qprinter.cpp:632
PageOrder pageOrder() const
Returns the current page order.
Definition: qprinter.cpp:1286
void setDoubleSidedPrinting(bool enable)
Enables double sided printing if doubleSided is true; otherwise disables it.
Definition: qprinter.cpp:1679
~QPrinter()
Destroys the printer object and frees any allocated resources.
Definition: qprinter.cpp:725
static int cupsVersion()
Definition: qcups_p.h:75
qreal toReal(bool *ok=0) const
Returns the variant as a qreal if the variant has type() Double , QMetaType::Float ...
Definition: qvariant.cpp:2740
void getPageMargins(qreal *left, qreal *top, qreal *right, qreal *bottom, Unit unit) const
Returns the page margins for this printer in left, top, right, bottom.
Definition: qprinter.cpp:1853
void setPrinterName(const QString &)
Sets the printer name to name.
Definition: qprinter.cpp:845
#define ABORT_IF_ACTIVE(location)
Definition: qprinter.cpp:82
static void setup()
Definition: qtextcodec.cpp:718
void setPreviewMode(bool)
Definition: qprinter.cpp:216
PaperSource
This enum type specifies what paper source QPrinter is to use.
Definition: qprinter.h:103
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
uint had_default_engines
Definition: qprinter_p.h:126
PrintEnginePropertyKey
This enum is used to communicate properties between the print engine and QPrinter.
Definition: qprintengine.h:60
QPrinter::OutputFormat outputFormat
Definition: qprinter_p.h:109
QString printProgram() const
Returns the name of the program that sends the print output to the printer.
Definition: qprinter.cpp:1005
void setOutputFileName(const QString &)
Sets the name of the output file to fileName.
Definition: qprinter.cpp:976