9#include <qpa/qplatformprintplugin.h>
10#include <qpa/qplatformprintersupport.h>
17#include <private/qpagedpaintdevice_p.h>
22#if QT_CONFIG(printpreviewwidget)
23#include <private/qpaintengine_preview_p.h>
30#define ABORT_IF_ACTIVE(location) \
31 if (d->printEngine->printerState() == QPrinter::Active) { \
32 qWarning("%s: Cannot be changed while printer is active", location); \
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); \
49 if (printerToUse.isNull()) {
51 if (printerToUse.isNull()) {
53 if (!availablePrinterNames.isEmpty())
71 if (ps && !printerToUse.isNull()) {
73 printerName = printerToUse.printerName();
81 static const QHash<QPrinter::PdfVersion, QPdfEngine::PdfVersion> engineMapping {
104 if (oldPrintEngine) {
114 prop = oldPrintEngine->property(
key);
121 delete oldPrintEngine;
124#if QT_CONFIG(printpreviewwidget)
125QList<const QPicture *> QPrinterPrivate::previewPages()
const
128 return previewEngine->pages();
129 return QList<const QPicture *>();
132bool QPrinterPrivate::previewMode()
const
134 return (previewEngine !=
nullptr) && (previewEngine ==
printEngine);
137void QPrinterPrivate::setPreviewMode(
bool enable)
147 q->setEngines(previewEngine, previewEngine);
179 qWarning(
"QPrinter::setPageLayout: Cannot be changed while printer is active");
195 qWarning(
"QPrinter::setPageLayout: Cannot be changed while printer is active");
221 QPair<QMarginsF, QPageLayout::Unit> pair =
qMakePair(margins,
units);
468 qFatal(
"QPrinter: Must construct a QCoreApplication before a QPrinter");
496 if (
d->use_default_engine)
497 delete d->printEngine;
501 d->use_default_engine =
false;
512 if (
d->use_default_engine)
513 delete d->printEngine;
514#if QT_CONFIG(printpreviewwidget)
515 delete d->previewEngine;
558 if (!printerToUse.isNull())
559 d->changeEngines(
format, printerToUse);
573 return d->outputFormat;
587 if (
d->pdfVersion == version)
590 d->pdfVersion = version;
605 return d->pdfVersion;
646 if (
name.isEmpty()) {
652 if (printerToUse.isNull())
679 return d->validPrinter;
1195 return d->printEngine->metric(
id);
1204 return d->paintEngine;
1215 return d->printEngine;
1229 const QList<QVariant> varlist
1232 intlist.reserve(varlist.size());
1233 for (
const auto &
var : varlist)
1251 return d->printEngine->newPage();
1266 return d->printEngine->abort();
1277 return d->printEngine->printerState();
1280#if defined(Q_OS_WIN) || defined(Q_QDOC)
1292QList<QPrinter::PaperSource> QPrinter::supportedPaperSources()
const
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)
1447 return d->printRange;
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
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.
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.
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.
bool isEquivalentTo(const QPageSize &other) const
Returns true if this page is equivalent to the other page, i.e.
QPageLayout pageLayout() const
QPagedPaintDevicePrivate * d
PdfVersion
The PdfVersion enum describes the version of the PDF file that is produced by QPrinter or QPdfWriter.
virtual Type type() const =0
Reimplement this function to return the paint engine \l{Type}.
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
bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units) override
virtual ~QPrinterPagedPaintDevicePrivate()
QPageLayout pageLayout() const override
QPrinterPagedPaintDevicePrivate(QPrinter *p)
bool setPageOrientation(QPageLayout::Orientation orientation) override
bool setPageSize(const QPageSize &pageSize) override
QPrinterInfo findValidPrinter(const QPrinterInfo &printer=QPrinterInfo())
QPrinter::PdfVersion pdfVersion
void initEngines(QPrinter::OutputFormat format, const QPrinterInfo &printer)
QPrinter::OutputFormat outputFormat
QPrinter::PrinterMode printerMode
QSet< QPrintEngine::PrintEnginePropertyKey > m_properties
QPrintEngine * printEngine
void init(const QPrinterInfo &printer, QPrinter::PrinterMode mode)
QPaintEngine * realPaintEngine
QPaintEngine * paintEngine
void changeEngines(QPrinter::OutputFormat format, const QPrinterInfo &printer)
QPrintEngine * realPrintEngine
void setProperty(QPrintEngine::PrintEnginePropertyKey key, const QVariant &value)
static QPrinterPrivate * get(QPrinter *printer)
QRectF paperRect(Unit) const
bool supportsMultipleCopies() const
void setFontEmbeddingEnabled(bool enable)
PdfVersion pdfVersion() const
QString creator() const
Returns the name of the application that created the document.
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.
void setEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine)
This function is used by subclasses of QPrinter to specify custom print and paint engines (printEngin...
void setPrintProgram(const QString &)
Sets the name of the program that should do the print job to printProg.
void setPaperSource(PaperSource)
Sets the paper source setting to source.
void setCollateCopies(bool collate)
QString printProgram() const
Returns the name of the program that sends the print output to the printer.
void setPdfVersion(PdfVersion version)
ColorMode colorMode() const
Returns the current color mode.
OutputFormat
The OutputFormat enum is used to describe the format QPrinter should use for printing.
int devType() const override
QPaintEngine * paintEngine() const override
Returns the paint engine used by the printer.
void setOutputFormat(OutputFormat format)
ColorMode
This enum type is used to indicate whether QPrinter should print in color or not.
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.
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...
void setColorMode(ColorMode)
Sets the printer's color mode to newColorMode, which can be either Color or GrayScale.
PaperSource paperSource() const
Returns the printer's paper source.
QString outputFileName() const
Returns the name of the output file.
void setFromTo(int fromPage, int toPage)
PrinterMode
This enum describes the mode the printer should work in.
PrintRange printRange() const
bool abort()
Aborts the current print run.
void setOutputFileName(const QString &)
Sets the name of the output file to fileName.
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
PrinterState printerState() const
Returns the current state of the printer.
QPrinter(PrinterMode mode=ScreenResolution)
Creates a new printer object with the given mode.
QString printerName() const
Returns the printer name.
void setDocName(const QString &)
Sets the document name to name.
void setCreator(const QString &)
Sets the name of the application that created the document to creator.
PageOrder
This enum type is used by QPrinter to tell the application program how to print.
void setPageOrder(PageOrder)
Sets the page order to pageOrder.
PrintRange
Used to specify the print range selection option.
QString printerSelectionOption() const
Returns the printer options selection string.
OutputFormat outputFormat() const
bool collateCopies() const
void setPrinterName(const QString &)
Sets the printer name to name.
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.
PageOrder pageOrder() const
Returns the current page order.
\inmodule QtCore\reentrant
iterator insert(const T &value)
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
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 >
Combined button and popup list for selecting options.
static const QCssKnownValue properties[NumProperties - 1]
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLsizei const GLfloat * v
[13]
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum format
GLsizei GLsizei GLchar * source
GLdouble GLdouble GLdouble GLdouble q
QT_BEGIN_NAMESPACE constexpr decltype(auto) qMakePair(T1 &&value1, T2 &&value2) noexcept(noexcept(std::make_pair(std::forward< T1 >(value1), std::forward< T2 >(value2))))
QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits)
#define ABORT_IF_ACTIVE(location)
qreal qt_pixelMultiplier(int resolution)
static int toInt(const QChar &qc, int R)
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)