PDA

View Full Version : QPrinter setOutputFileName



maartenS
16th November 2008, 13:54
Hi,

I'm trying to save a QDocument as pdf file on a specific location.

QPrinter toPdf;
toPdf.setOutputFormat(QPrinter::PdfFormat);
toPdf.setOutputFileName("test.pdf");
works, but when I'm trying to write a pdf file to a certain directory, i.e. home directory:


QPrinter toPdf;
toPdf.setOutputFormat(QPrinter::PdfFormat);
toPdf.setOutputFileName("~/test.pdf");
it doesn't work and I get this message:

QPainter::begin(): Returned false


Does anyone know how to solve this or if there is another way of doing this?
Thanks!

wysota
16th November 2008, 23:41
Isn't ~ interpreted by the shell? You don't have a shell here thus you should provide a valid path, like /home/myusername/test.pdf or QString("%1/test.pdf").arg(genenv("HOME")).

maartenS
17th November 2008, 13:59
Thanks! That was the problem.