How i can draw html page?
QWebView *view = new QWebView();
view.Load(Url("http://www.google.com"));
QPrinter printer = new Qprinter();
How I can draw this view?
How i can draw html page?
QWebView *view = new QWebView();
view.Load(Url("http://www.google.com"));
QPrinter printer = new Qprinter();
How I can draw this view?
In case you simply want to print the page, just use the QWebView::print(QPrinter *)
method.
If you want to draw the view to an arbitrary paint device, use QWebView::render(QPaintDevice *)
. This method is available on any QWidget
subclass.
view = new QWebView();
view->load(QUrl("http://www.google.com"));
setCentralWidget(view);
QPrinter *qPrinter = new QPrinter(QPrinter::HighResolution);
qPrinter->setOutputFormat(QPrinter::PdfFormat);
qPrinter->setOutputFileName("out.pdf");
view->print(qPrinter);
Do not worked! Please help me.
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{ QWebView view = new QWebView(this); //Set settings view->settings()->setAttribute(QWebSettings::JavaEnabled, true); view->settings()->setAttribute(QWebSettings::JavascriptEnabled, true); view->settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, false); view->settings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, false); view->settings()->setAttribute(QWebSettings::AutoLoadImages, true); //Load URl view->page()->mainFrame()->load(QUrl("http://www.habrahabr.ru")); //Connect signal loadFinished connect(view, SIGNAL(loadFinished(bool)), SLOT(finishLoading(bool))) }
void MainWindow::finishLoading(bool) { //Printing QPrinter *printer = new QPrinter(QPrinter::HighResolution); printer->setPrinterName("Microsoft XPS Document Writer"); printer->setOutputFileName("out.xps"); view->page()->mainFrame()->print(printer); }
Almost everything works, except for small parts. Do not tell my how to configure? FontFamily, FontSize, footer and header, link...