printing QWebView before showing in Dialog
Hi,
I'm trying to print a QWebview before it is showed in the Dialog
Code:
QString html
= getHtmlString
();
// Get the HTML String ui.webView->setHtml(html); // set the Html string to the QWebView
printer.
setOutputFormat(QPrinter::PdfFormat);
printer.
setOrientation(QPrinter::Landscape);
if(fileName.length()>0 ){
printer.setOutputFileName(fileName);
ui.webView->print(&printer); // print the QWebview
}
The printed html pdf is always white.
If I print the webview by pressing a button after it has been shown on the Dialog there's text in the pdf.
Can anyone help me?
Thanks,
Grisu
Re: printing QWebView before showing in Dialog
I am not certain about this because I was having the same problem. But I think you have to wait until after the QWebView::loadFinished() signal has been emitted. When you click the button, you probably have given it enough time to load (does it load after returning to the event loop?).