wv->setHtml(sTemplate, QUrl(QApplication::applicationDirPath() + "/templates"));
C++ (Qt)void QWebFrame::setUrl ( const QUrl & url )
wv->settings()->setUserStyleSheetUrl(QUrl::fromLocalFile("print.css"));
wv->settings()->setUserStyleSheetUrl(QUrl::fromLocalFile(QApplication::applicationDirPath() + "/templates/print.css"));
QWebView *wv = new QWebView(this); QWebSettings::globalSettings()->setFontFamily(QWebSettings::StandardFont, "Times New Roman"); wv->setHtml(sTemplate); QApplication::processEvents(); QPrintPreviewDialog *printPreview; printPreview = new QPrintPreviewDialog(new QPrinter(QPrinter::HighResolution), this, Qt::Dialog); connect(printPreview, SIGNAL(paintRequested(QPrinter*)), wv, SLOT(print(QPrinter*))); QSettings settings("tb.ini", QSettings::IniFormat); settings.beginGroup("Geometry"); printPreview->restoreGeometry(settings.value("PrintPreviewDialog").toByteArray()); printPreview->exec(); settings.setValue("PrintPreviewDialog", printPreview->saveGeometry()); delete printPreview;
QPrinter *printer = new QPrinter(QPrinter::HighResolution);printer->setDocName("Members");