I have a file that I'd like to print.
Is it possible (a good idea?) to use QPrintDialog/QPrinter for that?
When I do
Qt Code:
  1. QPrintDialog dialog(&printer, myDialog);
  2. if (dialog.exec()) {
  3. // now I got a printer, but how to print the file...?
  4. qDebug() << "how to print to" << printer.printerName();
  5. }
To copy to clipboard, switch view to plain text mode 
I'd rather not just call "lpr -PMYPRINTER MYFILE" (ugly).

Moreover, the QPrintDialog allows the user to specify the number of copies etc.
If I don't print via QPrinter, how could/should I make an external viewer use those settings?


So, my question boils down to:
  • can I print a file with Qt? (i.e. use Qt's printer selection, and have Qt send my file via 'the appropriate channels' to that printer; assuming the printer does understand the file type)
  • (I do not want to implement the drawing itself!),
  • or do I have to use an external program for that?



(I'd like to avoid calling something platform dependent, otherwise I might just call KDE's kprinter.)

Christoph