My application commonly uses a specific printer (that prints on labels); this is not the system wide default printer. Thus, the QPrintDialog should open with the label-printer pre-selected. While I have a solution (shown below), it is a very ugly work-around (tested on Ubuntu 14.04 / Qt 5.4) that I expect to fail on other OS or in future Qt versions.
Qt Code:
  1. QPrinter* printer = printerInfo.isNull() ? new QPrinter(QPrinter::HighResolution) : new QPrinter(printerInfo, QPrinter::HighResolution);
  2. qDebug() << "next show print dialog for printer" << printer->printerName();
  3. QPrintDialog printDlg(printer);
  4. qDebug() << "selected in print dialog" << printer->printerName() << ", but should be" << printerInfo.printerName();
  5. QList<QWidget*> childWidgets = printDlg.findChildren<QWidget*>(QLatin1String("printers"), Qt::FindChildrenRecursively);
  6. if (childWidgets.count() == 1) {
  7. QComboBox* comboBox(qobject_cast<QComboBox*>(childWidgets.at(0)));
  8. if (comboBox && comboBox->findText(printerInfo.printerName())) {
  9. comboBox->setCurrentText(printerInfo.printerName());}}
  10. if (printDlg.exec() == QDialog::Accepted) {
To copy to clipboard, switch view to plain text mode 
The output from lines 2 and 4 shows that providing a pre-selected QPrinter object to the constructor of QPrintDialog does not do the trick:
next show print dialog for printer "psc-1100-series"
selected in print dialog "Farbdrucker" , but should be "psc-1100-series"
Is there a clean way to have an application-specific printer pre-selected in a QPrintDialog?