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


C++ QWebFrame::toHtml方法代码示例

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


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

示例1: htmlOrSvgDump

void MyTextBrowser::htmlOrSvgDump(const char *filename)
{
#ifdef NO_WEBKIT
  FILE *fout = fopen(filename,"w");
  if(fout == NULL)
  {
    printf("could not write %s\n", filename);
    return;
  }
  QString xml = toHtml();
  fputs(xml.toUtf8(), fout);
  fclose(fout);
#else
  QWebPage *p = page();
  if(p == NULL) return;
  QWebFrame *f = p->currentFrame();
  if(f == NULL) return;

  FILE *fout = fopen(filename,"w");
  if(fout == NULL)
  {
    printf("could not write %s\n", filename);
    return;
  }
  QString xml = f->toHtml();
  fputs(xml.toUtf8(), fout);
  fclose(fout);
#endif  
}
开发者ID:pvbrowser,项目名称:pvb,代码行数:29,代码来源:MyTextBrowser_v4.cpp

示例2: handleFinishStreamLoading

void STab::handleFinishStreamLoading(bool)
{
    qDebug("STab::handleFinishStreamLoading");

    disconnect(ui->webView, SIGNAL(loadFinished(bool)), this, SLOT(handleFinishStreamLoading(bool)));

    ui->progressBar->setValue(99);

    //
    QSettings* const settings = Settings::getHostsInstance();
    settings->beginGroup(this->currentGroup);
    QString mode = settings->value("mode").toString();
    if (mode == QString("regexps")) {
        QWebFrame *frame = ui->webView->page()->mainFrame();
        QString content = frame->toHtml();

        int size = settings->beginReadArray("rule");
        for (int i = 0; i < size; ++i) {
            settings->setArrayIndex(i);

            QRegExp rx(settings->value("from").toString());
            content.replace(rx, settings->value("to").toString());
        }

        settings->endArray();

        qDebug() << content;

        ui->webView->setContent(content.toUtf8());
    }
    settings->endGroup();

    prepareUi();
}
开发者ID:GoliathUA,项目名称:Qt_Duckling-Viewer,代码行数:34,代码来源:stab.cpp

示例3: dump

void DumpRenderTree::dump()
{
    // Prevent any further frame load or resource load callbacks from appearing after we dump the result.
    DumpRenderTreeSupportQt::dumpFrameLoader(false);
    DumpRenderTreeSupportQt::dumpResourceLoadCallbacks(false);

    QWebFrame *mainFrame = m_page->mainFrame();

    if (isStandAloneMode()) {
        QString markup = mainFrame->toHtml();
        fprintf(stdout, "Source:\n\n%s\n", markup.toUtf8().constData());
    }

    QString mimeType = DumpRenderTreeSupportQt::responseMimeType(mainFrame);
    if (mimeType == "text/plain")
        m_controller->dumpAsText();

    // Dump render text...
    QString resultString;
    if (m_controller->shouldDumpAsText())
        resultString = dumpFramesAsText(mainFrame);
    else {
        resultString = mainFrame->renderTreeDump();
        resultString += dumpFrameScrollPosition(mainFrame);
    }
    if (!resultString.isEmpty()) {
        fprintf(stdout, "Content-Type: text/plain\n");
        fprintf(stdout, "%s", resultString.toUtf8().constData());

        if (m_controller->shouldDumpBackForwardList()) {
            fprintf(stdout, "%s", dumpBackForwardList(webPage()).toUtf8().constData());
            foreach (QObject* widget, windows) {
                QWebPage* page = qobject_cast<QWebPage*>(widget->findChild<QWebPage*>());
                fprintf(stdout, "%s", dumpBackForwardList(page).toUtf8().constData());
            }
开发者ID:mcgrawp,项目名称:webkit-webcl,代码行数:35,代码来源:DumpRenderTreeQt.cpp

示例4: toHtml

QString QWebFrameProto::toHtml() const
{
  scriptDeprecated("QWebFrame will not be available in future versions");
  QWebFrame *item = qscriptvalue_cast<QWebFrame*>(thisObject());
  if (item)
    return item->toHtml();
  return QString();
}
开发者ID:xtuple,项目名称:qt-client,代码行数:8,代码来源:qwebframeproto.cpp

示例5: import_paper

//----------------------------------------------------------------
void Collection::import_paper()
{
  //we should not try to add a paper if no current library;
  if ( !_current_library )
    {
      QMessageBox::about(this, tr("Error"),
			 tr("Error: you have no Libraries defined\n"
			    "you cannot create a new paper"));
      return;
    }
  QWebPage * page = _rss_box->page();
  
  QWebFrame * frame = page->mainFrame();

  //now create a new paper and parse out the values we want.
  _parser->setData(frame->toHtml());
  _stdout << "Collection::import_paper title" << _parser->getTitle() << endl;
  _stdout << "Collection::import_paper authors" << _parser->getAuthors() << endl;

  Paper * paper = new Paper();
  paper->set_title(_parser->getTitle());
  paper->set_author(_parser->getAuthors());
  paper->set_abstract(_parser->getAbstract());
  paper->set_date(_parser->getDate());
  paper->set_arxiv_number(_parser->getNumber());

  //Download the damn thing
  _manager = new QNetworkAccessManager(this);
  _manager->get(QNetworkRequest(_parser->getDownloadLocation()));
  connect(_manager, SIGNAL(finished(QNetworkReply*)),
  	  this, SLOT(download_finished(QNetworkReply*)));

  QDir directory(_current_library->get_library_directory()+"/"+_parser->getPaperName());

  _stdout << "Collection::import_paper " <<  directory.absolutePath() << endl; 

  paper->set_file_name(directory.absolutePath());
  
  //add the entry to the library
  _current_library->add_entry(paper);

  //add the entry to the list
  add_paper_to_list(*paper,_paper_list);
  update_library_list();

}
开发者ID:lindenle,项目名称:QTpapers,代码行数:47,代码来源:Collection.cpp

示例6: applyEncoding

void WebView::applyEncoding()
{
	if (m_encoding_in_progress)
		return;

	if (webPage() && webPage()->mainWindow())
	{
		QString enc = webPage()->mainWindow()->m_currentEncoding;
		if (enc.isEmpty())
			return;

		if (enc == m_current_encoding && m_current_encoding_url == url() )
			return;

		QWebPage *page = webPage();
		if (!page)
			return;

		QWebFrame *mainframe = page->mainFrame();
		if (!mainframe)
			return;

		QString html = mainframe->toHtml();

		QTextCodec *codec = QTextCodec::codecForName( enc.toAscii() );
		if (!codec)
			return;

		QTextDecoder *decoder = codec->makeDecoder();
		if (!decoder)
			return;

		m_encoding_in_progress = true;
		m_current_encoding = enc;
		m_current_encoding_url = url();
		QString output = decoder->toUnicode(html.toAscii());
		mainframe->setHtml(output, mainframe->url());

		QList<QWebFrame *> children = mainframe->childFrames();
		foreach(QWebFrame *frame, children)
		{
			html = frame->toHtml();
			output = decoder->toUnicode(html.toAscii());
			frame->setHtml(output, frame->url());
		}
开发者ID:OS2World,项目名称:APP-INTERNET-QtWeb,代码行数:45,代码来源:webview.cpp

示例7: tempAuthPageLoaded

void OAuthWindow::tempAuthPageLoaded(bool rc) {
    QLOG_DEBUG() << "Temporary credentials received from Evernote";
    if (!rc) {
        errorMessage = tr("Error receiving temporary credentials");
        error = true;
        QWebFrame *mainFrame = tempAuthPage.page()->mainFrame();
        QString contents = mainFrame->toHtml();
        QLOG_DEBUG() << "Reply contents:" << contents;
        close();
        return;
    }

    QWebFrame *mainFrame = tempAuthPage.page()->mainFrame();
    QString contents = mainFrame->toPlainText();
    QLOG_DEBUG() << "Temporary Cred Contents: " << contents;
    int index = contents.indexOf("&oauth_token_secret");
    contents = contents.left(index);
    QUrl accessUrl(urlBase+"/OAuth.action?" +contents);

    connect(userLoginPage.page()->networkAccessManager(),SIGNAL(finished(QNetworkReply*)),this,SLOT(userLoginReply(QNetworkReply*)));
    userLoginPage.load(accessUrl);
    grid.addWidget(&userLoginPage);
}
开发者ID:,项目名称:,代码行数:23,代码来源:

示例8: parseProductPage

void ArestShopPlugin::parseProductPage()
{
#ifdef USE_WEBKIT
	QWebFrame * ptrFrame = getWebPage()->mainFrame();
	printPageContent(ptrFrame->toHtml());
	QWebElement elCompFullName = ptrFrame->findFirstElement("h1[class=nazwatowaru]");
	QWebElement elPrice = ptrFrame->findFirstElement("span[class=price]"); //div class="altFontFace price"
	QString strPrice = elPrice.toPlainText();
	for(int i = 0;i<strPrice.size();i++)
	{
		if (strPrice.at(i).isLetterOrNumber())
			continue;
		strPrice = strPrice.left(i);
		break;
	}
	m_stCompData.dPrice = strPrice.toDouble();
	m_stCompData.eSearchResult = SR_COMPFOUND;
	m_stCompData.strCompURL = getWebPage()->mainFrame()->url().toString();
#endif
#ifdef USE_XML_PARSER
	m_stCompData.dPrice = Arest::dPrice;
	m_stCompData.eSearchResult = SR_COMPFOUND;
#endif
}
开发者ID:T4ng10r,项目名称:ComputerComponentsShop,代码行数:24,代码来源:ArestShop.cpp

示例9: updateTextEdit

void Html_Viewer::updateTextEdit()
{
   QWebFrame *mainFrame = ui->webView->page()->mainFrame();
   QString frameText = mainFrame->toHtml();
   ui->plainTextEdit->setPlainText(frameText);
}
开发者ID:wpbest,项目名称:copperspice,代码行数:6,代码来源:html_viewer.cpp

示例10: saveSnapshot

void CutyCapt::saveSnapshot() {
  QWebFrame *mainFrame = mPage->mainFrame();
  QPainter painter;
  const char* format = NULL;

  for (int ix = 0; CutyExtMap[ix].id != OtherFormat; ++ix) {
    if (CutyExtMap[ix].id == mFormat) {
      format = CutyExtMap[ix].identifier;
    }
  }

  // TODO: sometimes contents/viewport can have size 0x0 in which case saving
  // them will fail. This is likely the result of the method being called too
  // early. So far I've been unable to find a workaround, except using --delay
  // with some substantial wait time. I've tried to resize multiple time, make
  // a fake render, check for other events... This is primarily a problem under
  // my Ubuntu virtual machine.

  mPage->setViewportSize( mainFrame->contentsSize() );

  switch (mFormat) {
    case SvgFormat: {
      QSvgGenerator svg;
      svg.setFileName(mOutput);
      svg.setSize(mPage->viewportSize());
      painter.begin(&svg);
      mainFrame->render(&painter);
      painter.end();
      break;
    }
    case PdfFormat:
    case PsFormat: {
      QPrinter printer;
      printer.setPageSize(QPrinter::A4);
      printer.setOutputFileName(mOutput);
      // TODO: change quality here?
      mainFrame->print(&printer);
      break;
    }
#if QT_VERSION < 0x050000
    case RenderTreeFormat:
      QFile file(mOutput);
      file.open(QIODevice::WriteOnly | QIODevice::Text);
      QTextStream s(&file);
      s.setCodec("utf-8");
      s << mainFrame->renderTreeDump();
      break;
    }
#endif
    case InnerTextFormat:
    case HtmlFormat: {
      QFile file(mOutput);
      file.open(QIODevice::WriteOnly | QIODevice::Text);
      QTextStream s(&file);
      s.setCodec("utf-8");
      s << (mFormat == InnerTextFormat ? mainFrame->toPlainText() : (mFormat == HtmlFormat ? mainFrame->toHtml() : "bug"));
      break;
    }
    default: {
      QImage image(mPage->viewportSize(), QImage::Format_ARGB32);
      painter.begin(&image);
      mainFrame->render(&painter);
      painter.end();
      // TODO: add quality
      image.save(mOutput, format);
    }
  };
开发者ID:sstelfox,项目名称:CutyCapt,代码行数:67,代码来源:CutyCapt.cpp

示例11: updateTextEdit

//! [7]
void MainWindow::updateTextEdit()
{
    QWebFrame *mainFrame = centralWidget->webView->page()->mainFrame();
    QString frameText = mainFrame->toHtml();
    centralWidget->plainTextEdit->setPlainText(frameText);
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:7,代码来源:mainwindow.cpp


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