本文整理汇总了C++中QWebFrame::toPlainText方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebFrame::toPlainText方法的具体用法?C++ QWebFrame::toPlainText怎么用?C++ QWebFrame::toPlainText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebFrame
的用法示例。
在下文中一共展示了QWebFrame::toPlainText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: permanentCredentialsReceived
void OAuthWindow::permanentCredentialsReceived(bool rc) {
if (authTokenReceived)
return;
QWebFrame *mainFrame;
mainFrame = authRequestPage.page()->mainFrame();
QString contents = mainFrame->toPlainText();
if (!rc) {
errorMessage = tr("Error receiving permanent credentials");
QLOG_DEBUG() << "Bad return code while receiveng permanent credentials";
error = true;
return;
close();
}
if (contents.startsWith("oauth_token=S%3D")) {
QLOG_DEBUG() << "Permanent Auth Response: " << contents;
QLOG_DEBUG() << "Permanent credentials received received from Evernote";
authTokenReceived = true;
QLOG_DEBUG() << "Good authorization token received.";
QString decoded;
QByteArray enc;
enc.append(contents);
decoded = QUrl::fromEncoded(enc).toString();
response = decoded;
userLoginPage.disconnect(this);
tempAuthPage.disconnect(this);
authRequestPage.disconnect(this);
error = false;
errorMessage = "";
close();
}
}
示例2: toPlainText
QString QWebFrameProto::toPlainText() const
{
scriptDeprecated("QWebFrame will not be available in future versions");
QWebFrame *item = qscriptvalue_cast<QWebFrame*>(thisObject());
if (item)
return item->toPlainText();
return QString();
}
示例3: getTitle
QString NoteItem::getTitle()
{
if(m_readOnly)
return m_title->text();
else {
QString title = m_titleEdit->text();
if(title == "" || title == tr("Untitled")) {
if(m_rich) {
QWebFrame* mainFrame = m_webView->page()->mainFrame();
QWebFrame* iframe = mainFrame->childFrames()[0];
title = MainWindow::getTitleFromContent(iframe->toPlainText());
}
else
title = MainWindow::getTitleFromContent(m_textEdit->toPlainText());
}
return title;
}
}
示例4: 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);
}
示例5: 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);
}
};