Solved print preview widget
-
void MainWindow::on_actionPrint_triggered()
{
QPrinter *printer = new QPrinter(QPrinter::HighResolution);
printer->setOutputFormat(QPrinter::PdfFormat);printer->setPaperSize(QPrinter::A4);
printer->setOrientation(QPrinter::Landscape);
printer->setFullPage(true);
//printer->setResolution(100);
printer->setOutputFileName("Desktop//aaaa.pdf");QPrintPreviewWidget *preview =0;
preview = new QPrintPreviewWidget(printer,preview);preview->print();
connect(preview, SIGNAL(paintRequested(QPrinter*)),allWorkspaceShapes[currentIndex]->drawShape,SLOT(Print(QPrinter*)));
preview->show();
}
i used this and still didn't get anything, i have another problem in the code maybe?
-
@rest said in print preview widget:
That is NOT a valid path
setOutputFileName("Desktop//aaaa.pdf");Please use a valid full path and only single /
like
C:/Users/SOMEUSERNAME/Desktop/test.pdf -
printer->setOutputFileName("C:/Users/admin/Desktop/test.pdf");
i tried and nothing :( -
and you do have write access there ?
and the path IS real. meaning u didnt make up the admin name. -
@mrjj and then i used this and still does not work
printer->setOutputFileName("C:/Users/Public/Public Documents/test.pdf"); -
@rest
and it does show stuff in preview ?
but the file is NOT created? -
exactly, it shows but it's not saved
-
@rest
and u press print inside preview ?
to make it actually print and not just preview ? -
@mrjj solved, i had make the print preview and printer object in the constructor of the window
-
@rest
oh, so moving them helped? -
@mrjj yes, thanks