Hi there,
Ok. Now I am going crazy...
Can anyone tell me why this works:
void Partitura::print()
{
printer.
setOrientation(QPrinter::Portrait);
if(dlg.
exec()==QDialog::Accepted) { scene->render(&p);
p.end();
}
}
void Partitura::print()
{
QPrinter printer(QPrinter::HighResolution);
printer.setPageSize(QPrinter::A4);
printer.setOrientation(QPrinter::Portrait);
QPrintDialog dlg(&printer);
if(dlg.exec()==QDialog::Accepted) {
QPainter p(&printer);
scene->render(&p);
p.end();
}
}
To copy to clipboard, switch view to plain text mode
... and this does not work:
void Partitura::exportPDF()
{
printer.
setOrientation(QPrinter::Portrait);
printer.
setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(fileName);
scene->render(&p);
p.end();
}
void Partitura::exportPDF()
{
QString fileName = QFileDialog::getSaveFileName(this, "Export PDF",
QString(), "*.pdf");
QPrinter printer(QPrinter::HighResolution);
printer.setPageSize(QPrinter::A4);
printer.setOrientation(QPrinter::Portrait);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(fileName);
QPainter p(&printer);
scene->render(&p);
p.end();
}
To copy to clipboard, switch view to plain text mode
scene is a QGraphicsScene object declared as global.
The debugger returns a stack overflow when running the 2nd function.
If i comment the line scene->render(&p); the problem disappears, but obviously i don't get the scene contents on the pdf...
Thanks in advance.
Tiago Campos
Bookmarks