1#if 0 2// ! [0] 3int main(int argc, char **argv) 4{ 5 QApplication app(argc, argv); 6 const int width = 640; 7 const int height = 480; 8 9 QGraphicsScene scene; 10 11 QGraphicsView view(&scene); 12 view.setFrameShape(QFrame::NoFrame); 13 view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 14 view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 15 16 QGraphicsWebView webview; 17 webview.resize(width, height); 18 webview.load(QUrl("http://doc.qt.nokia.com/")); 19 20 scene.addItem(&webview); 21 22 view.resize(width, height); 23 view.show(); 24 25 return app.exec(); 26} 27// ! [0] 28 29 30// ! [1] 31webview.setResizesToContents(true); 32// ! [1] 33 34// ! [2] 35class MobileWebView : public QGraphicsWidget { 36 Q_OBJECT 37public: 38 MobileWebView(QGraphicsItem *parent = 0); 39 ~MobileWebView(); 40 41 bool mousePress(const QPoint &value); 42 void mouseMove(const QPoint &value); 43 void mouseRelease(const QPoint &value); 44 45private: 46 QGraphicsWebView* webView; 47}; 48// ! [2] 49 50// ! [3] 51webview.page()->setPreferredContentsSize(QSize(desiredWidth, desiredHeight)); 52// ! [3] 53 54// ! [4] 55QWebSettings::globalSettings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, true); 56// ! [4] 57 58// ! [5] 59QWebSettings::globalSettings()->setAttribute(QWebSettings::FrameFlatteningEnable, true); 60// ! [5] 61#endif 62