printing a(n existing) file in Qt
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
Code:
if (dialog.exec()) {
// now I got a printer, but how to print the file...?
qDebug() << "how to print to" << printer.printerName();
}
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
Re: printing a(n existing) file in Qt
anyone got an idea? please?
Re: printing a(n existing) file in Qt
Whats the harm in using QPrinter ??
Also you can have a look at QPrinter::setPrintProgram if u are using X11
See also - QWidget::render
Re: printing a(n existing) file in Qt
Hi aamer4yu. Thank you.
The harm is as follows:
* QPrinter lets the user configure stuff; if I use a custom external program, I would want those options passed on and understood
* (I am on X11; would prefer non-platform spec. stuff though) QPrinter::setPrintProgram() can indeed be used; however it does not solve the painting part (I still have to paint myself). It only changes the printing backend.
* QWidget::render is no real help; I do not want to render stuff myself. I have a defined set of files (ASCII, PostScript, PDF) that I would like to be printed. I have no desire to implement rendering those myself. (Although I already did that once for postscript.)
What I would like is the possibility to pass an existing (e.g.) postscript file to QPrinter and just use its configuration capabilites.