void QDeclarativeWebView::setPage(QWebPage* page) { if (d->view->page() == page) return; d->view->setPage(page); updateContentsSize(); page->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); page->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); connect(page->mainFrame(), SIGNAL(urlChanged(QUrl)), this, SLOT(pageUrlChanged())); connect(page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString))); connect(page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(iconChanged())); connect(page->mainFrame(), SIGNAL(iconChanged()), this, SIGNAL(iconChanged())); connect(page->mainFrame(), SIGNAL(initialLayoutCompleted()), this, SLOT(initialLayout())); connect(page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SIGNAL(contentsSizeChanged(QSize))); connect(page, SIGNAL(loadStarted()), this, SLOT(doLoadStarted())); connect(page, SIGNAL(loadProgress(int)), this, SLOT(doLoadProgress(int))); connect(page, SIGNAL(loadFinished(bool)), this, SLOT(doLoadFinished(bool))); connect(page, SIGNAL(statusBarMessage(QString)), this, SLOT(setStatusText(QString))); connect(page->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(windowObjectCleared())); page->settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, true); }
void MyWebView::initEvents() { // 委托页面所有连接在当前视图中打开 myPage->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); connect(myPage, SIGNAL(linkClicked(QUrl)), this, SLOT(onOpenUrl(QUrl))); // 对所有事件添加信号槽 connect(myFrame, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool))); connect(myFrame, SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(onJavaScriptWindowObjectCleared())); connect(myFrame, SIGNAL(initialLayoutCompleted()), this, SLOT(onInitialLayoutCompleted())); connect(myFrame, SIGNAL(pageChanged()), this, SLOT(onPageChanged())); connect(myFrame, SIGNAL(contentsSizeChanged(const QSize)), this, SLOT(onContentsSizeChanged(const QSize))); connect(myFrame, SIGNAL(iconChanged()), this, SLOT(onIconChanged())); connect(myFrame, SIGNAL(loadStarted()), this, SLOT(onLoadStarted())); connect(myFrame, SIGNAL(titleChanged(const QString)), this, SLOT(onTitleChanged(const QString))); connect(myFrame, SIGNAL(urlChanged(const QUrl)), this, SLOT(onUrlChanged(const QUrl))); connect(myPage, SIGNAL(loadProgress(int)), this, SLOT(onLoadProgress(int))); connect(myPage, SIGNAL(repaintRequested(const QRect)), this, SLOT(onRepaintRequested(const QRect))); connect(myPage, SIGNAL(geometryChangeRequested(const QRect)), this, SLOT(onGeometryChangeRequested(const QRect))); connect(newManager, SIGNAL(requestFinished(QString)), this, SLOT(onRequestFinished(QString))); connect(newManager, SIGNAL(requestStart(QString)), this, SLOT(onRequestStart(QString))); };
void WebPage::handleFrameCreated(QWebFrame *frame) { //qDebug() << "frame created = " << frame->frameName() << " " << frame->url(); FrameInit *frameInit = new FrameInit(frame); connect(frame, SIGNAL(urlChanged(const QUrl &)), frameInit, SLOT(handleUrlChanged(const QUrl &))); connect(frame, SIGNAL(initialLayoutCompleted()), frameInit, SLOT(handleFrameLayoutComplete())); }
void WebPage::frameCreated(QWebFrame* frame) { connect(frame, SIGNAL(initialLayoutCompleted()), this, SLOT(frameInitialLayoutCompleted())); }
int QWebFrame::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: javaScriptWindowObjectCleared(); break; case 1: provisionalLoad(); break; case 2: titleChanged((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 3: urlChanged((*reinterpret_cast< const QUrl(*)>(_a[1]))); break; case 4: initialLayoutCompleted(); break; case 5: iconChanged(); break; case 6: contentsSizeChanged((*reinterpret_cast< const QSize(*)>(_a[1]))); break; case 7: loadStarted(); break; case 8: loadFinished((*reinterpret_cast< bool(*)>(_a[1]))); break; case 9: { QVariant _r = evaluateJavaScript((*reinterpret_cast< const QString(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< QVariant*>(_a[0]) = _r; } break; case 10: print((*reinterpret_cast< QPrinter*(*)>(_a[1]))); break; default: ; } _id -= 11; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< qreal*>(_v) = textSizeMultiplier(); break; case 1: *reinterpret_cast< qreal*>(_v) = zoomFactor(); break; case 2: *reinterpret_cast< QString*>(_v) = title(); break; case 3: *reinterpret_cast< QUrl*>(_v) = url(); break; case 4: *reinterpret_cast< QUrl*>(_v) = requestedUrl(); break; case 5: *reinterpret_cast< QUrl*>(_v) = baseUrl(); break; case 6: *reinterpret_cast< QIcon*>(_v) = icon(); break; case 7: *reinterpret_cast< QSize*>(_v) = contentsSize(); break; case 8: *reinterpret_cast< QPoint*>(_v) = scrollPosition(); break; case 9: *reinterpret_cast< bool*>(_v) = hasFocus(); break; } _id -= 10; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setTextSizeMultiplier(*reinterpret_cast< qreal*>(_v)); break; case 1: setZoomFactor(*reinterpret_cast< qreal*>(_v)); break; case 3: setUrl(*reinterpret_cast< QUrl*>(_v)); break; case 8: setScrollPosition(*reinterpret_cast< QPoint*>(_v)); break; } _id -= 10; } else if (_c == QMetaObject::ResetProperty) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 10; } #endif // QT_NO_PROPERTIES return _id; }