本文整理汇总了C++中QWebFrame类的典型用法代码示例。如果您正苦于以下问题:C++ QWebFrame类的具体用法?C++ QWebFrame怎么用?C++ QWebFrame使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QWebFrame类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWebPage
QString ForumProbe::getTitle(QString &html) {
QString title;
#ifndef NO_WEBKITWIDGETS
QWebPage *page = new QWebPage();
QWebFrame *frame = page->mainFrame();
frame->setHtml(html);
title = frame->title();
page->deleteLater();
#else
int titleBegin = html.indexOf("<title>");
if(titleBegin > 0) {
int titleEnd = html.indexOf("</", titleBegin);
title = html.mid(titleBegin + 7, titleEnd - titleBegin - 7);
}
#endif
return title;
}
示例2: page
void AlertWebApp::updateContentRect()
{
QWebFrame* frame = page()->page()->mainFrame();
QWebElement el = frame->findFirstElement("[x-palm-popup-content]");
QRect r;
if (!el.isNull()) {
r = el.geometry();
r.setLeft(MAX(0, r.left()));
r.setRight(MIN(r.right(), (int) m_windowWidth));
r.setTop(MAX(0, r.top()));
r.setBottom(MIN(r.bottom(), (int) m_windowHeight));
}
m_channel->sendAsyncMessage(new ViewHost_Alert_SetContentRect(routingId(),
r.left(), r.right(),
r.top(), r.bottom()));
}
示例3: page
void CustomWebView::handleAutoscroll ()
{
if (!ScrollDelta_)
return;
AccumulatedScrollShift_ += ScrollDelta_;
if (std::abs (AccumulatedScrollShift_) >= 1)
{
QWebFrame *mf = page ()->mainFrame ();
QPoint pos = mf->scrollPosition ();
pos += QPoint (0, AccumulatedScrollShift_);
mf->setScrollPosition (pos);
AccumulatedScrollShift_ -= static_cast<int> (AccumulatedScrollShift_);
}
}
示例4: qWarning
void HelpPage::onHandleUnsupportedContent(QNetworkReply *reply)
{
// sub resource of this page
if (m_loadingUrl != reply->url()) {
qWarning() << "Resource" << reply->url().toEncoded() << "has unknown Content-Type, will be ignored.";
reply->deleteLater();
return;
}
// set a default error string we are going to display
QString errorString = HelpViewer::tr("Unknown or unsupported Content!");
if (reply->error() == QNetworkReply::NoError) {
// try to open the url using using the desktop service
if (QDesktopServices::openUrl(reply->url())) {
reply->deleteLater();
return;
}
// seems we failed, now we show the error page inside creator
} else {
errorString = reply->errorString();
}
// setup html
const QString html = QString::fromLatin1(g_htmlPage).arg(g_percent1, errorString,
HelpViewer::tr("Error loading: %1").arg(reply->url().toString()), g_percent4, g_percent5, g_percent6,
g_percent7);
// update the current layout
QList<QWebFrame*> frames;
frames.append(mainFrame());
while (!frames.isEmpty()) {
QWebFrame *frame = frames.takeFirst();
if (frame->url() == reply->url()) {
frame->setHtml(html, reply->url());
return;
}
QList<QWebFrame *> children = frame->childFrames();
foreach (QWebFrame *frame, children)
frames.append(frame);
}
if (m_loadingUrl == reply->url())
mainFrame()->setHtml(html, reply->url());
}
示例5: url
void KWebKitPart::slotMainFrameLoadFinished (bool ok)
{
if (!ok || !m_doLoadFinishedActions)
return;
m_doLoadFinishedActions = false;
if (!m_emitOpenUrlNotify) {
m_emitOpenUrlNotify = true; // Save history once page loading is done.
}
// If the document contains no <title> tag, then set it to the current url.
if (m_webView->title().trimmed().isEmpty()) {
// If the document title is empty, then set it to the current url
const QUrl url (m_webView->url());
const QString caption (url.toString((QUrl::RemoveQuery|QUrl::RemoveFragment)));
emit setWindowCaption(caption);
// The urlChanged signal is emitted if and only if the main frame
// receives the title of the page so we manually invoke the slot as a
// work around here for pages that do not contain it, such as text
// documents...
slotUrlChanged(url);
}
QWebFrame* frame = page()->mainFrame();
if (!frame || frame->url() == *globalBlankUrl)
return;
// Set the favicon specified through the <link> tag...
if (WebKitSettings::self()->favIconsEnabled()
&& !frame->page()->settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) {
const QWebElement element = frame->findFirstElement(QL1S("head>link[rel=icon], "
"head>link[rel=\"shortcut icon\"]"));
QUrl shortcutIconUrl;
if (!element.isNull()) {
shortcutIconUrl = frame->baseUrl().resolved(QUrl(element.attribute("href")));
//kDebug() << "setting favicon to" << shortcutIconUrl;
m_browserExtension->setIconUrl(shortcutIconUrl);
}
}
slotFrameLoadFinished(ok);
}
示例6: webPage
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());
}
示例7: page
void WebView::paintEvent(QPaintEvent * event)
{
QWebView::paintEvent(event);
QWebFrame *frameff = page()->mainFrame();
int hValue = frameff->scrollBarValue(Qt::Horizontal);
int vValue = frameff->scrollBarValue(Qt::Vertical);
if (hValue != _lastHorizontalValue || vValue != _lastVerticalValue)
{
_lastHorizontalValue = hValue;
_lastVerticalValue = vValue;
emit scrollValueChanged();
}
}
示例8: QSKIP
void tst_QWebView::reusePage()
{
if (!QDir(TESTS_SOURCE_DIR).exists())
QSKIP(QString("This test requires access to resources found in '%1'").arg(TESTS_SOURCE_DIR).toLatin1().constData(), SkipAll);
QDir::setCurrent(TESTS_SOURCE_DIR);
QFETCH(QString, html);
QWebView* view1 = new QWebView;
QPointer<QWebPage> page = new QWebPage;
view1->setPage(page);
page->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
QWebFrame* mainFrame = page->mainFrame();
mainFrame->setHtml(html, QUrl::fromLocalFile(TESTS_SOURCE_DIR));
if (html.contains("</embed>")) {
// some reasonable time for the PluginStream to feed test.swf to flash and start painting
waitForSignal(view1, SIGNAL(loadFinished(bool)), 2000);
}
示例9: on_webPageLoadFinished
void CWebNewsLoader::on_webPageLoadFinished(bool res)
{
if (res)
{
QWebFrame *frame = m_webView->page()->mainFrame();
QWebElement document = frame->documentElement();
QWebElementCollection elements = document.findAll("li a");
QStringList newsList;
foreach (QWebElement element, elements)
newsList.append(element.toPlainText());
emit newsListLoadFinished(m_webView->url().toString(), newsList);
}
delete m_webView;
}
示例10: 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;
}
}
示例11: wrapInFunction
void wrapInFunction()
{
//! [0]
// ...
QWebFrame *frame = myWebPage->mainFrame();
frame->addToJavaScriptWindowObject("someNameForMyObject", myObject);
// ...
//! [0]
#if 0
//! [1]
{
width: ...,
height: ...,
toDataURL: function() { ... },
assignToHTMLImageElement: function(element) { ... }
toImageData: function() { ... }
}
示例12: activateOn
void FlickScroll::activateOn(QWebView *webView)
{
QWebFrame *frame = webView->page()->mainFrame();
frame->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
frame->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
webView->installEventFilter(this);
int removed = flickScroll_pm->flickData.remove(webView);
printf("FlickScroll::activateOn removed %d items from hash\n", removed);
FlickData * newFlickData = new FlickData();
flickScroll_pm->flickData[webView] = newFlickData;
newFlickData->widget = webView;
newFlickData->state = FlickData::Steady;
}
示例13: set_repaint_throttle
bool PropertyChanger::set_repaint_throttle(QString value)
{
QWebFrame* pFrame = static_cast < QWebFrame* > ( this->parent() );
QWebPage* pPage = NULL;
if ( pFrame != NULL )
pPage = pFrame->page();
else
return false;
if ( pPage == NULL )
return false;
//TODO: check values
pPage->setProperty("_q_RepaintThrottlingPreset", value);
return true;
}
示例14: Q_ASSERT
bool LoadItem::invoke() const
{
//qDebug() << ">>>LoadItem::invoke";
Q_ASSERT(m_webPage);
QWebFrame* frame = 0;
const QString t = target();
if (t.isEmpty())
frame = m_webPage->mainFrame();
else
frame = findFrameNamed(t, m_webPage->mainFrame());
if (!frame)
return false;
frame->load(url());
return true;
}
示例15: decodeMessage
void lmcMessageLog::appendPublicMessage(QString* lpszUserId, QString* lpszUserName, QString* lpszMessage,
QDateTime *pTime, QFont *pFont, QColor *pColor) {
QString html = QString::null;
bool localUser = (lpszUserId->compare(localId) == 0);
decodeMessage(lpszMessage);
QString fontStyle = getFontStyle(pFont, pColor, localUser);
if(lpszUserId->compare(lastId) != 0) {
outStyle = !outStyle;
html = outStyle ? themeData.outMsg : themeData.inMsg;
// get the avatar image for this user from the cache folder
QString filePath = participantAvatars.value(*lpszUserId);
// if image not found, use the default avatar image for this user
QString iconPath = QFile::exists(filePath) ? QUrl::fromLocalFile(filePath).toString() : "qrc"AVT_DEFAULT;
html.replace("%iconpath%", iconPath);
html.replace("%sender%", *lpszUserName);
html.replace("%time%", getTimeString(pTime));
html.replace("%style%", fontStyle);
html.replace("%message%", *lpszMessage);
QWebFrame* frame = page()->mainFrame();
QWebElement document = frame->documentElement();
QWebElement body = document.findFirst("body");
body.appendInside(html);
} else {
html = outStyle ? themeData.outNextMsg : themeData.inNextMsg;
html.replace("%time%", getTimeString(pTime));
html.replace("%style%", fontStyle);
html.replace("%message%", *lpszMessage);
QWebFrame* frame = page()->mainFrame();
QWebElement document = frame->documentElement();
QWebElement body = document.findFirst("body");
QWebElement last = body.lastChild();
QWebElement insert = last.findFirst("div#insert");
insert.replace(html);
}
hasData = true;
}