Skip to content

Instantly share code, notes, and snippets.

@nowrep
Created January 19, 2013 22:15
Show Gist options
  • Save nowrep/4575569 to your computer and use it in GitHub Desktop.
Save nowrep/4575569 to your computer and use it in GitHub Desktop.
#include <QApplication>
#include <QWebView>
#include <QPrintPreviewDialog>
class Test : public QWidget
{
Q_OBJECT
public:
QWebView* view;
Test() : QWidget()
{
view = new QWebView();
view->load(QUrl("http://www.google.com"));
view->show();
connect(view, SIGNAL(loadFinished(bool)), this, SLOT(finished()));
}
private slots:
void finished()
{
QPrintPreviewDialog dialog;
connect(&dialog, SIGNAL(paintRequested(QPrinter*)), view, SLOT(print(QPrinter*)));
dialog.exec();
}
};
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
new Test();
return app.exec();
}
#include "moc_main.cpp"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment