summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qprinter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/painting/qprinter.cpp')
-rw-r--r--src/gui/painting/qprinter.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/gui/painting/qprinter.cpp b/src/gui/painting/qprinter.cpp
index 6c309c7..154d90c 100644
--- a/src/gui/painting/qprinter.cpp
+++ b/src/gui/painting/qprinter.cpp
@@ -285,6 +285,10 @@ void QPrinterPrivate::addToManualSetList(QPrintEngine::PrintEnginePropertyKey ke
the printProgram() function can be used to specify the command or utility
to use instead of the system default.
+ Note that setting parameters like paper size and resolution on an
+ invalid printer is undefined. You can use QPrinter::isValid() to
+ verify this before changing any parameters.
+
QPrinter supports a number of parameters, most of which can be
changed by the end user through a \l{QPrintDialog}{print dialog}. In
general, QPrinter passes these functions onto the underlying QPrintEngine.
@@ -740,7 +744,7 @@ void QPrinter::setOutputFormat(OutputFormat format)
#ifndef QT_NO_PDF
Q_D(QPrinter);
- if (d->outputFormat == format)
+ if (d->validPrinter && d->outputFormat == format)
return;
d->outputFormat = format;
@@ -769,8 +773,8 @@ void QPrinter::setOutputFormat(OutputFormat format)
if (def_engine)
delete oldPrintEngine;
- d->validPrinter = d->outputFormat == QPrinter::PdfFormat || d->outputFormat == QPrinter::PostScriptFormat;
-
+ if (d->outputFormat == QPrinter::PdfFormat || d->outputFormat == QPrinter::PostScriptFormat)
+ d->validPrinter = true;
#else
Q_UNUSED(format);
#endif
@@ -830,11 +834,15 @@ void QPrinter::setPrinterName(const QString &name)
#endif
QList<QPrinterInfo> prnList = QPrinterInfo::availablePrinters();
- d->validPrinter = false;
- for (int i = 0; i < prnList.size(); ++i) {
- if (prnList[i].printerName() == name) {
- d->validPrinter = true;
- break;
+ if (name.isEmpty()) {
+ d->validPrinter = d->outputFormat == QPrinter::PdfFormat || d->outputFormat == QPrinter::PostScriptFormat;
+ } else {
+ d->validPrinter = false;
+ for (int i = 0; i < prnList.size(); ++i) {
+ if (prnList[i].printerName() == name) {
+ d->validPrinter = true;
+ break;
+ }
}
}