Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #include <QApplication>
  2. #include <QGraphicsView>
  3. #include <QGraphicsWebView>
  4. #include <QPainter>
  5. #include <QWebView>
  6.  
  7. class WebWidget : public QGraphicsView
  8. {
  9. public:
  10. WebWidget()
  11. {
  12. setFrameShape(NoFrame);
  13. setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing | QPainter::HighQualityAntialiasing);
  14. setScene(new QGraphicsScene(this));
  15. scene()->addItem(&m_webview);
  16. m_webview.focusWidget();
  17. m_webview.resize(1000, 1000);
  18. }
  19.  
  20. void loadUrl(const QUrl &url)
  21. {
  22. m_webview.load(url);
  23. }
  24.  
  25. protected:
  26. QGraphicsWebView m_webview;
  27. };
  28. int main(int argc, char *argv[])
  29. {
  30. QApplication::setGraphicsSystem(QLatin1String("raster"));
  31. QApplication app(argc, argv);
  32.  
  33. const QStringList arguments = QCoreApplication::arguments();
  34. if (QCoreApplication::arguments().size() != 2) {
  35. qWarning("You must pass the page to load as the first argument");
  36. return 1;
  37. }
  38.  
  39. QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
  40.  
  41. WebWidget view;
  42. view.loadUrl(QUrl(arguments.last()));
  43. view.showMaximized();
  44.  
  45. return app.exec();
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement