example.using.QWebView.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. #include <QApplication>
  2. #include <QWebView>
  3. #include <QString>
  4. /* An earlier implementation that uses QWebView. Works good but
  5. * on the rpi it currently does not support hardware acceleration.
  6. *
  7. * See https://trac.webkit.org/wiki/QtWebKitTiling:
  8. * "QWebView is based on the QWidget system, thus it cannot
  9. * easily support rotation, overlays, hardware accelerated
  10. * compositing and tiling."
  11. *
  12. * This browser might be reincarnated if hardware acceleration is not needed
  13. * or gets implemented into QWebView.
  14. */
  15. int main(int argc, char** argv) {
  16. QApplication app(argc, argv);
  17. QString url;
  18. QWebView view;
  19. // Read first application argument as url.
  20. if (1 < app.arguments().count()) {url = app.arguments().at(1);}
  21. else {url = "http://localhost";}
  22. // Hide the cursor (it still exists).
  23. QApplication::setOverrideCursor(Qt::BlankCursor);
  24. // Disable scrollbars.
  25. view.page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
  26. view.page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
  27. // Set full screen.
  28. view.showFullScreen();
  29. // Open a url.
  30. view.setUrl(QUrl(url));
  31. return app.exec();
  32. }