Unsolved QPrinter initialization
-
Hello,
What is the difference of these two sequences initializing the QPrinter?
-
Using QPrinterinfo directly without any dialog:
QPrinterInfo printerInfo = QPrinterInfo::printerInfo("Printer NN");
QPrinter printer(printerInfo,QPrinter::HighResolution); -
Using QPrintDialog to select the printer:
QPrinter printer(QPrinter::HighResolution);
QPrintDialog dialog(&printer, this);
if (dialog.exec() != QDialog::Accepted)
return;
When printing, I experience that method number 2 works as expected, while method number 1 is stretching the output horizontally.
In this case I would prefere to print without an extra dialog, but cannot figure out what "magic" the QPrintDialog does to my QPrinter. -
-
@mads-l When using QPrintDialog you should use the printer user selected/configured in the dialog (http://doc.qt.io/qt-5/qprintdialog.html#printer). Do you?
-
@mads-l how is this topic different from https://forum.qt.io/topic/97637/qprinter-the-output-becomes-stretched ?
-
@jsulm I do, and it is working fine in this situation. I am using a label printer, and the size of the label is according to the properties of the setup in the printer driver. When using the QPrinterInfo with the name of the printer in the QPrinter constructor it fails.
-
@aha_1980 I am working with the same problem, but this is a more generalized presentation of the problem.
-
@mads-l
Hi
You can check out what QPrintDialog does via
https://code.woboq.org/qt5/qtbase/src/printsupport/dialogs/
all code is hot linked so its easy to navigate.