title: Print a PDF file using Qt
body: <p>I want to open and print a PDF file from particular path, My previous code work perfectly open and directly send print command to printer.
  Now what I want is multiple printer are there and I have to select one, and after that I want send print command, I don't want want use QPrintDialog, My printer name are stored in a TextBox and retrieve that name and print it through that printer which I set in textbox:</p>
  
  <p>my previous code mention below:</p>
  
  <pre><code>#include &lt;QSettings&gt;
  #include &lt;QProcess&gt;
  #include &lt;QDebug&gt;
  
  int main(int argc, char *argv[])
  {
      const QString classesRoot = "HKEY_CLASSES_ROOT";
  
      // get ID of .pdf extension
      QSettings pdfSettings(classesRoot + "\\.pdf", QSettings::NativeFormat);
      QString pdfId = pdfSettings.value("Default").toString();
  
      // get path to default program that associated with PDF files
      QString printPath = QSettings(classesRoot + "\\" + pdfId + "\\shell\\print\\command", QSettings::NativeFormat).value("Default").toString();
      QString openPath = QSettings(classesRoot + "\\" + pdfId + "\\shell\\open\\command", QSettings::NativeFormat).value("Default").toString();
      qDebug() &lt;&lt; "print path" &lt;&lt; printPath;
      qDebug() &lt;&lt; "open path" &lt;&lt; openPath;
  
      // open .pdf file
      QProcess::startDetached(openPath.arg("full path to pdf file.pdf") );
  
      // print .pdf file
      QProcess printProcess;
      printProcess.start(printPath.arg("full path to pdf file.pdf") );
      printProcess.waitForFinished(-1);
  
      return 0;
  }
  </code></pre>