Ok, so I put the following together based on you advice:
void MainWindow
::print(QPrinter* printer
) {
painter.begin(printer);
webEngineView->render(&painter);
painter.end();
}
void MainWindow::print(QPrinter* printer)
{
QPainter painter;
painter.begin(printer);
webEngineView->render(&painter);
painter.end();
}
To copy to clipboard, switch view to plain text mode
void MainWindow::printPreview()
{
QPrintPreviewDialog preview(&printer, this);
preview.exec();
}
void MainWindow::printPreview()
{
QPrinter printer;
QPrintPreviewDialog preview(&printer, this);
connect(&preview, SIGNAL(paintRequested(QPrinter*)), SLOT(print(QPrinter*)));
preview.exec();
}
To copy to clipboard, switch view to plain text mode
When I call printPreview I do get the preview dialogue now and I can see the page ( though it is tiny, but I can work with the scaling issue later ), however after about 2 or 3 seconds the program crashes. Anything obvious I'm missing here?
Added after 21 minutes:
Never mind. This does work as expected, there was another, unrelated problem causing the crash.
Bookmarks