@ChrisW67
Thanks for your hints, how to approach the problem. My extended code snipet now looks as follows:
printerInfo = QPrinterInfo::printerInfo(QStringLiteral("Farbdrucker"));
qDebug() << "printer selected in printerInfo:" << (printerInfo.isNull() ? tr("not set") : tr("%1 (%2)").arg(printerInfo.printerName()).arg(printerInfo.description()));
qDebug() << "selected printer" << printer->printerName();
testPainter.begin(printer);
printer->newPage();
testPainter.end();
printerInfo = QPrinterInfo::printerInfo(QStringLiteral("Farbdrucker"));
qDebug() << "printer selected in printerInfo:" << (printerInfo.isNull() ? tr("not set") : tr("%1 (%2)").arg(printerInfo.printerName()).arg(printerInfo.description()));
QPrinter* printer = new QPrinter(printerInfo /*, QPrinter::HighResolution*/);
qDebug() << "selected printer" << printer->printerName();
QPainter testPainter;
testPainter.begin(printer);
printer->newPage();
testPainter.end();
To copy to clipboard, switch view to plain text mode
- The color printer is connected and other applications are able to print to it.
- It attempts to print to the system-wide default printer TLP2742.
When I select a different printer as system wide default, e.g., print-to-pdf, then the code snipet works properly! Thus, it seems that the issue is specifically with the printer TLP2742 (an offline printer, i.e., it should print to a file). I will further look into this and report back. (I still consider it unexpected behavior / bug that a potentially misconfigured printer TLP2742 messes up the printer selection in a Qt program that deliberately avoids to print to the TLP2742).
[EDIT]
I can now confirm that the issue is related to the driver for the default printer that is incomplete or broken. Still not good, of course: this means that an end-user error outside of my control has the potential to break some functionality of my Qt application.
Bookmarks