print preview widget
-
@mrjj said in print preview widget:
printer.setOutputFileName(filename);
you control where with setOutputFileName
make sure to use / and not \ for the full path to the file -
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?
-
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 -
@mrjj and then i used this and still does not work
printer->setOutputFileName("C:/Users/Public/Public Documents/test.pdf"); -
@mrjj solved, i had make the print preview and printer object in the constructor of the window