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