#include #include class MyGraphicsWebView : public QWebView { Q_OBJECT public: MyGraphicsWebView() : QWebView() {} public slots: void printTheFrame() { QPrinter printer(QPrinter::HighResolution); QPrintDialog *dialog = new QPrintDialog(&printer); if (dialog->exec() == QDialog::Accepted) { page()->setViewportSize(QSize(1200,1200)); page()->mainFrame()->print(&printer); } } }; #include "main.moc" int main(int argc, char **argv) { QApplication a(argc, argv); const int width = 640; const int height = 480; MyGraphicsWebView webview; webview.load(QUrl("file:///C:/Users/anshaw/tasks/TestReport.html")); webview.show(); QTimer::singleShot(5000, &webview, SLOT(printTheFrame())); a.exec(); return 0; }