Created
March 19, 2014 10:33
-
-
Save ttldtor/9639164 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
QWebView *MuWebView::createWindow(QWebPage::WebWindowType type) { | |
Q_UNUSED(type) | |
QWebView* webView = new QWebView; | |
QWebPage* webPage = new QWebPage(webView); | |
webView->setWindowModality(Qt::ApplicationModal); | |
webView->setAttribute(Qt::WA_DeleteOnClose, true); | |
webView->setPage(webPage); | |
connect(webPage, &QWebPage::printRequested, [&](QWebFrame *frame) { | |
if (!frame) { | |
return; | |
} | |
QPrintPreviewDialog* printPreviewDialog = new QPrintPreviewDialog(); | |
connect(printPreviewDialog, &QPrintPreviewDialog::paintRequested, [&](QPrinter* printer){ | |
frame->print(printer); | |
}); | |
printPreviewDialog->exec(); | |
printPreviewDialog->disconnect(); | |
printPreviewDialog->deleteLater(); | |
}); | |
webView->show(); | |
return webView; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment