Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <QApplication>
- #include <QGraphicsView>
- #include <QGraphicsWebView>
- #include <QPainter>
- #include <QWebView>
- class WebWidget : public QGraphicsView
- {
- public:
- WebWidget()
- {
- setFrameShape(NoFrame);
- setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing | QPainter::HighQualityAntialiasing);
- setScene(new QGraphicsScene(this));
- scene()->addItem(&m_webview);
- m_webview.focusWidget();
- m_webview.resize(1000, 1000);
- }
- void loadUrl(const QUrl &url)
- {
- m_webview.load(url);
- }
- protected:
- QGraphicsWebView m_webview;
- };
- int main(int argc, char *argv[])
- {
- QApplication::setGraphicsSystem(QLatin1String("raster"));
- QApplication app(argc, argv);
- const QStringList arguments = QCoreApplication::arguments();
- if (QCoreApplication::arguments().size() != 2) {
- qWarning("You must pass the page to load as the first argument");
- return 1;
- }
- QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
- WebWidget view;
- view.loadUrl(QUrl(arguments.last()));
- view.showMaximized();
- return app.exec();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement