当前位置: 首页>>代码示例>>C++>>正文


C++ QWebPage::mainFrame方法代码示例

本文整理汇总了C++中QWebPage::mainFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebPage::mainFrame方法的具体用法?C++ QWebPage::mainFrame怎么用?C++ QWebPage::mainFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QWebPage的用法示例。


在下文中一共展示了QWebPage::mainFrame方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updateResizesToContentsForPage

void QGraphicsWebViewPrivate::updateResizesToContentsForPage()
{
    ASSERT(page);

    if (resizesToContents) {
        // resizes to contents mode requires preferred contents size to be set
        if (!page->preferredContentsSize().isValid())
            page->setPreferredContentsSize(QSize(960, 800));

#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
        QObject::connect(page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)),
                         q, SLOT(_q_contentsSizeChanged(const QSize&)), Qt::UniqueConnection);
#else
        QObject::connect(page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)),
                         q, SLOT(_q_contentsSizeChanged(const QSize&)));
#endif
    } else {
开发者ID:dirlinch,项目名称:chromecast-mirrored-source.vendor,代码行数:17,代码来源:qgraphicswebview.cpp

示例2: setWebView

void BrowserApi::setWebView(QWebView *view)
{
    QWebPage *page = view->page();
    m_frame = page->mainFrame();

    attachObject();
    connect(m_frame, SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(attachObject()));
}
开发者ID:bwarden,项目名称:mythtv,代码行数:8,代码来源:mythuiwebbrowser.cpp

示例3: loadingFinished

void SourceViewer::loadingFinished()
{
    QWebPage page;
    QByteArray response = m_reply->readAll();
    page.mainFrame()->setContent(response, QString(), m_request->url());

    /* If original request was POST or a different problem is there, fall
       back to modified version of QWebFrame.toHtml() */
    if (page.mainFrame()->toHtml() != *m_source)
        m_edit->setPlainText(*m_source);
    else
        m_edit->setPlainText(QLatin1String(response));

    m_reply->close();
    delete m_request;
    delete m_source;
}
开发者ID:smarter,项目名称:arora,代码行数:17,代码来源:sourceviewer.cpp

示例4: createWindow

Page* ChromeClientQt::createWindow(Frame*, const FrameLoadRequest& request, const WindowFeatures& features)
{
    QWebPage *newPage = m_webPage->createWindow(features.dialog ? QWebPage::WebModalDialog : QWebPage::WebBrowserWindow);
    if (!newPage)
        return 0;
    newPage->mainFrame()->load(request.resourceRequest().url());
    return newPage->d->page;
}
开发者ID:halfkiss,项目名称:ComponentSuperAccessor,代码行数:8,代码来源:ChromeClientQt.cpp

示例5: createModalDialog

Page* ChromeClientQt::createModalDialog(Frame*, const FrameLoadRequest& request)
{
    QWebPage *newPage = m_webPage->createWindow(QWebPage::WebModalDialog);
    if (!newPage)
        return 0;
    newPage->mainFrame()->load(request.resourceRequest().url());
    return newPage->d->page;
}
开发者ID:pk-codebox-evo,项目名称:remixos-usb-tool,代码行数:8,代码来源:ChromeClientQt.cpp

示例6: viewModeChanged

void HTMLDocument::viewModeChanged(int tabNumber)
{
    switch (tabNumber)
    {
        case 0:
        if (this->currentMode == Code)
        {
            this->code = this->editor->toPlainText();
            this->designArea->page()->mainFrame()->setHtml(this->editor->toPlainText());
        }
        else if (this->currentMode == Preview)
        {
            this->designArea->setHtml(this->code);
        }
        this->currentMode = Design;
        break;
        case 1: //going to code mode
        if (this->currentMode ==  Design)
        {
            QWebPage *page = this->designArea->page();
            this->code = page->mainFrame()->toHtml();
            this->editor->setPlainText(this->code);
            this->editor->setFocus();
        }
        else if (this->currentMode == Preview)
        {
            this->editor->setPlainText(this->code);
        }
        this->currentMode = Code;
        break;
        case 2:
        if (this->currentMode == Design)
        {
            QWebPage *page = this->designArea->page();
            this->code = page->mainFrame()->toHtml();
        }
        else if (this->currentMode == Code)
        {
            this->code = this->editor->toPlainText();
        }
        this->currentMode = Preview;
        this->previewArea->setHtml(this->code);
        break;
    }

}
开发者ID:nodesman,项目名称:flare,代码行数:46,代码来源:htmldocument.cpp

示例7: openActionUrlInNewWindow

void WebView::openActionUrlInNewWindow()
{
    if (QAction *action = qobject_cast<QAction*>(sender())) {
        QWebPage *page = tabWidget()->getView(TabWidget::NewWindow, this)->page();
        QNetworkRequest request(action->data().toUrl());
        request.setRawHeader("Referer", url().toEncoded());
        page->mainFrame()->load(request);
    }
}
开发者ID:mariuz,项目名称:fram,代码行数:9,代码来源:webview.cpp

示例8: QString

void
message_view::prepend_body_fragment(const QString& fragment)
{
  QWebPage* page = m_bodyv->page();
  page->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
  QString js = QString("try {var b=document.getElementsByTagName('body')[0]; var p=document.createElement('div'); p.innerHTML=\"%1\"; b.insertBefore(p, b.firstChild); 1;} catch(e) { e; }").arg(escape_js_string(fragment));
  QVariant v = page->mainFrame()->evaluateJavaScript(js);
  page->settings()->setAttribute(QWebSettings::JavascriptEnabled, false);
}
开发者ID:,项目名称:,代码行数:9,代码来源:

示例9: diagnoseLoad

// --- DIAGNOSE LOAD ---
// Verify that the page loaded successfully, else present error message.
// If successful, set other data parts and handle filters.
void MainWindow::diagnoseLoad(bool ok) {
    setReloadButton();
    if (!ok) {
        //QMessageBox::critical(this, tr("Error"), tr("Failed to load the URL")); // FIXME: triggers crash with favicon path customized due to QtWebkit bug!
        // Don't return to the event loop.
    }
    else {
        //QWidget* tab = tabWidget->currentWidget
        tabWidget->setTabText(tabWidget->currentIndex(), wv->title());
        tabWidget->setTabIcon(tabWidget->currentIndex(), wv->icon());
        addressBar->setText(wv->url().toString());
        QString title = wv->title();
        if (title.size() > 200) {
            title.resize(200);
        }

        setWindowTitle(title + " - WildFox");

        // check the page URL against the filters
        if (extFilters.size() < 1) {
            return;
        }

        QWebPage* page = (QWebPage*) sender();
        if (page == 0) {
            return;
        }
        QWebFrame* frame = page->mainFrame();
        if (frame == 0) {
            return;
        }
        QString url = frame->url().path();
        QStringList urlbit = url.split("://");
        QDir extension;
        extension.setPath(manifest.fileName());
        if (urlbit.size() > 1) {
            QString scheme = urlbit[0];
            QStringList bits = urlbit[1].split(".");
            for (int i = 0; i < extFilters.size(); ++i) {
                if (extFilters[i].scheme != scheme) {
                    continue;
                }
                for (int j = 0; extFilters[i].segments.size(); ++j) {
                    if (extFilters[i].segments[j] != bits[j] && extFilters[i].segments[j] != "*") {
                        continue;
                    }
                }

                // matched filter, inject associated scripts into the content.
                QWebElement root = frame->documentElement();
                QWebElement head = root.findFirst("head");
                head.appendOutside("<script type=\"text/javascript\" src=\"" +
                                   extension.absolutePath() + "\" />");
            }
        }
    }
}
开发者ID:duckinator,项目名称:WildFox,代码行数:60,代码来源:mainwindow.cpp

示例10: dispatchCreatePage

WebCore::Frame* FrameLoaderClientQt::dispatchCreatePage()
{
    if (!m_webFrame)
        return 0;
    QWebPage *newPage = m_webFrame->page()->createWindow(QWebPage::WebBrowserWindow);
    if (!newPage)
        return 0;
    return newPage->mainFrame()->d->frame;
}
开发者ID:Marforius,项目名称:qt,代码行数:9,代码来源:FrameLoaderClientQt.cpp

示例11: onLoad

void Widget::onLoad()
{
	QWebPage *page = qobject_cast<QWebPage*>(sender());
	QElapsedTimer timer;
	timer.start();
	QStringList scripts = contentScripts();
	qDebug() << timer.elapsed(); timer.start();
	foreach (const QString &script, scripts) {
		page->mainFrame()->evaluateJavaScript(script);
	};
开发者ID:AlexeyProkhin,项目名称:qutim,代码行数:10,代码来源:widget.cpp

示例12: main

int main(int argc, char *argv[])
{
	struct sigaction action;
	memset(&action, 0, sizeof(struct sigaction));
	action.sa_handler = term;
	sigaction(SIGTERM, &action, NULL);

	int fps = atoi(argv[4]);
	int width = atoi(argv[2]);
	int height = atoi(argv[3]);

	init_shared_data(atoi(argv[2]), atoi(argv[3]));

	QApplication app(argc, argv);
	QWebPage page;

	QPalette palette = page.palette();
	palette.setBrush(QPalette::Base, Qt::transparent);
	page.setPalette(palette);

	page.mainFrame()->setUrl(QUrl::fromUserInput(argv[1]));
	page.setViewportSize(QSize(width, height));
	page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
	page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);

	pthread_mutex_lock(&data->mutex);
	QImage image(&data->data, width, height, QImage::Format_RGBA8888);
	QPainter painter(&image);
	pthread_mutex_unlock(&data->mutex);

	while (!done) {
		app.processEvents();

		pthread_mutex_lock(&data->mutex);
		image.fill(0);
		page.mainFrame()->render(&painter, QWebFrame::ContentsLayer);
		pthread_mutex_unlock(&data->mutex);

		usleep(1000000 / fps);
	}

	return 0;
}
开发者ID:JohanAR,项目名称:obs-qtwebkit,代码行数:43,代码来源:qtwebkit-renderer.cpp

示例13: onGetLyricPageResult

void LyricsManiaAPI::onGetLyricPageResult()
{
    QNetworkReply* reply = qobject_cast<QNetworkReply*>(QObject::sender());

    bool found = false;
    Lyric* lyric = 0;

    if (reply->error() != QNetworkReply::NoError) {
        qCritical() << "Cannot fetch lyric";
    } else {
        QWebPage page;
        page.settings()->setAttribute(QWebSettings::AutoLoadImages, false);
        page.settings()->setAttribute(QWebSettings::JavascriptEnabled, false);
        page.mainFrame()->setHtml(reply->readAll());

        QWebElement lyricbox = page.mainFrame()->findFirstElement("div[class=lyrics-body]");

        if (lyricbox.isNull()) {
            qCritical() << "Cannot find lyric text in HTML page";
        } else {
            // Remove the video div
            lyricbox.findFirst(QStringLiteral("div")).removeFromDocument();
            // Remove the song title
            lyricbox.findFirst(QStringLiteral("strong")).removeFromDocument();

            lyric = lyrics.take(reply);

            if (!lyric) {
                qCritical() << "Got an invalid lyric object!";
            } else {
                lyric->setText(lyricbox.toPlainText());

                found = true;
            }
        }
    }

    qDebug() << "Lyric found:" << found;
    Q_EMIT lyricFetched(lyric, found);

    reply->deleteLater();
}
开发者ID:Quent-in,项目名称:harbour-Lyrics,代码行数:42,代码来源:lyricsmaniaapi.cpp

示例14: forceRender

    void Editor::forceRender(QSize size)
    {
        QWebPage *page = m_webView->page();

        page->setViewportSize(size);

        QImage image(size.width(), size.height(), QImage::Format_Mono);
        QPainter painter(&image);

        page->mainFrame()->render(&painter);
    }
开发者ID:banlyst,项目名称:notepadqq,代码行数:11,代码来源:editor.cpp

示例15: onPageLoaded

void WebViewLoaderLoop::onPageLoaded()
{
	disconnect(m_pages.first().data(), 0, this, 0);
	m_pages.removeFirst();
	m_htmls.removeFirst();
	if (!m_pages.isEmpty()) {
		QWebPage *page = m_pages.first().data();
		QString html = m_htmls.first();
		page->mainFrame()->setHtml(html);
	}
}
开发者ID:AlexeyProkhin,项目名称:qutim,代码行数:11,代码来源:webkitmessageviewcontroller.cpp


注:本文中的QWebPage::mainFrame方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。