本文整理汇总了C++中QWebFrame::url方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebFrame::url方法的具体用法?C++ QWebFrame::url怎么用?C++ QWebFrame::url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebFrame
的用法示例。
在下文中一共展示了QWebFrame::url方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: url
QUrl QWebFrameProto::url() const
{
scriptDeprecated("QWebFrame will not be available in future versions");
QWebFrame *item = qscriptvalue_cast<QWebFrame*>(thisObject());
if (item)
return item->url();
return QUrl();
}
示例2: 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() + "\" />");
}
}
}
}
示例3: NotFoundPage
void ArestShopPlugin::NotFoundPage()
{
#ifdef USE_WEBKIT
QWebFrame * ptrFrame = getWebPage()->mainFrame();
m_stCompData.dPrice = 0;
m_stCompData.strCompURL = ptrFrame->url().toString();
m_stCompData.eSearchResult=SR_COMPNOTFOUND;
emit priceSearchedFinished(m_stCompData);
afterSearchCleanup();
#endif
}
示例4: handleUnsupportedContent
void WebPage::handleUnsupportedContent(QNetworkReply *reply)
{
if (reply->error() == QNetworkReply::ProtocolUnknownError) {
QSettings settings;
settings.beginGroup(QLatin1String("WebView"));
QStringList externalSchemes;
externalSchemes = settings.value(QLatin1String("externalSchemes")).toStringList();
if (externalSchemes.contains(reply->url().scheme()))
QDesktopServices::openUrl(reply->url());
return;
}
if (reply->error() == QNetworkReply::NoError) {
if (reply->header(QNetworkRequest::ContentTypeHeader).isValid())
BrowserApplication::downloadManager()->handleUnsupportedContent(reply);
return;
}
QFile file(QLatin1String(":/notfound.html"));
bool isOpened = file.open(QIODevice::ReadOnly);
Q_ASSERT(isOpened);
QString title = tr("Error loading page: %1").arg(reply->url().toString());
QString html = QString(QLatin1String(file.readAll()))
.arg(title)
.arg(reply->errorString())
.arg(reply->url().toString());
QBuffer imageBuffer;
imageBuffer.open(QBuffer::ReadWrite);
QIcon icon = view()->style()->standardIcon(QStyle::SP_MessageBoxWarning, 0, view());
QPixmap pixmap = icon.pixmap(QSize(32, 32));
if (pixmap.save(&imageBuffer, "PNG")) {
html.replace(QLatin1String("IMAGE_BINARY_DATA_HERE"),
QString(QLatin1String(imageBuffer.buffer().toBase64())));
}
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: FindFrame
QWebFrame* CustomWebPage::FindFrame (const QUrl& url)
{
QList<QWebFrame*> frames;
frames.append (mainFrame ());
while (!frames.isEmpty ())
{
QWebFrame *frame = frames.takeFirst ();
if (frame->url () == url)
return frame;
frames << frame->childFrames ();
}
return 0;
}
示例6: handleUnsupportedContent
void WebPage::handleUnsupportedContent(QNetworkReply *reply)
{
QString errorString = reply->errorString();
if (m_loadingUrl != reply->url()) {
// sub resource of this page
qWarning() << "Resource" << reply->url().toEncoded() << "has unknown Content-Type, will be ignored.";
reply->deleteLater();
return;
}
if (reply->error() == QNetworkReply::NoError && !reply->header(QNetworkRequest::ContentTypeHeader).isValid()) {
errorString = "Unknown Content-Type";
}
QFile file(QLatin1String(":/notfound.html"));
bool isOpened = file.open(QIODevice::ReadOnly);
Q_ASSERT(isOpened);
Q_UNUSED(isOpened)
QString title = tr("Error loading page: %1").arg(reply->url().toString());
QString html = QString(QLatin1String(file.readAll()))
.arg(title)
.arg(errorString)
.arg(reply->url().toString());
QBuffer imageBuffer;
imageBuffer.open(QBuffer::ReadWrite);
QIcon icon = view()->style()->standardIcon(QStyle::SP_MessageBoxWarning, 0, view());
QPixmap pixmap = icon.pixmap(QSize(32,32));
if (pixmap.save(&imageBuffer, "PNG")) {
html.replace(QLatin1String("IMAGE_BINARY_DATA_HERE"),
QString(QLatin1String(imageBuffer.buffer().toBase64())));
}
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());
}
}
示例7: slotMainFrameLoadFinished
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);
}
示例8: onHandleUnsupportedContent
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());
}
示例9: 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());
}
示例10: handleLoadFinished
void WebTabPanel::handleLoadFinished(bool) {
QWebFrame *frame = web->page()->mainFrame();
QString url=frame->url().toString();
//QMessageBox::information (0,"assdf",tr("Handle load finished, state: ")+QString::number(state)+tr(", url: ")+frame->url().toString());
infoArea->hide();
progress->hide();
loadingText->hide();
if (url=="http://twitter.com/login") {
if (!tweets->getAuthenticatingFetcher()) {
state=-1;
return;
}
QString user = tweets->getAuthenticatingFetcher()->getUsername();
QString pass = tweets->getAuthenticatingFetcher()->getPassword();
// Homepage login
//frame->evaluateJavaScript(tr("var f=document.getElementById('signin');document.getElementById('username').value=\"")+user+tr("\";document.getElementById('password').value=\"")+pass+tr("\";f.submit();"));
// redirect page login
loadingText->setText("Please wait, signing in to twitter...");
frame->evaluateJavaScript(tr("var f=document.forms[1];f['username_or_email'].value=\"")+user+tr("\";f['session[password]'].value=\"")+pass+tr("\";f.submit();"));
state=1;//loggin in
} else if (url=="http://twitter.com/invitations/find_on_twitter") {
// Now at being passed to twitter state
state=2;//Searching
web->show();
frame->evaluateJavaScript(tr("function $(s){return document.getElementById(s);}function __yasstlinks() {var i=['home_link','profile_link','settings_link','help_link','sign_out_link'];for (var b in i) {b=$(i[b]);b.style.display='none';}i=$('footer').firstChild.nextSibling.nextSibling.nextSibling.firstChild.nextSibling;while(i.nextSibling){i.parentNode.removeChild(i.nextSibling);}}__yasstlinks();"));
frame->setScrollPosition(QPoint(0,0));
//QTimer::singleShot(1000,this,SLOT(resetScroll()));
web->setEnabled(true);
handleTimeout();
} else if (url.startsWith(tr("http://twitter.com/"))) {
state=3;//Search results or user info.
frame->evaluateJavaScript(tr("function $(s){return document.getElementById(s);}function __yasstlinks() {var i=['home_link','profile_link','settings_link','help_link','sign_out_link'];for (var b in i) {b=$(i[b]);b.style.display='none';}i=$('footer').firstChild.nextSibling.nextSibling.nextSibling.firstChild.nextSibling;while(i.nextSibling){i.parentNode.removeChild(i.nextSibling);}}__yasstlinks();"));
frame->evaluateJavaScript(tr("function __yasst() {i=$('timeline');i.innerHTML='<style>.follow-actions input{display:none;} a.__yasst-followsingle {text-decoration:none; visibility:visible !important; -webkit-appearance: none; -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -webkit-box-align: center; -webkit-box-sizing: border-box; -webkit-rtl-ordering: logical; -webkit-user-select: text; background-color: rgb(230, 230, 230); border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; color: black; cursor: pointer; display: inline-block; font-family: \\'Lucida Grande\\'; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; height: 23px; letter-spacing: normal; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 8px; padding-right: 8px; padding-top: 4px; text-align: center; text-indent: 0px; text-shadow: none; text-transform: none; vertical-align: top; white-space: pre; width: 48px; word-spacing: 0px;} a:hover.__yasst-follow,a:hover.__yasst-followsingle{background-color: rgb(204, 204, 204);} a.__yasst-follow{visibility: visible !important; -webkit-appearance: none; -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -webkit-box-align: center; -webkit-box-sizing: border-box; -webkit-rtl-ordering: logical; -webkit-user-select: text; background-color: rgb(230, 230, 230); border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; color: black; cursor: pointer; display: none; font-family: \\'Lucida Grande\\'; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; height: auto; letter-spacing: normal; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 8px; padding-right: 8px; padding-top: 4px; text-align: center; text-indent: 0px; text-shadow: none; text-transform: none; vertical-align: top; white-space: pre; width: 80px; word-spacing: 0px;}</style>'+$('timeline').innerHTML;var e=document.getElementById('follow_control');if (e!=null) {var u=e.parentNode.parentNode.className;u=u.substr(u.lastIndexOf(' ')+1);var l=document.createElement('div');l.innerHTML='<a class=\\\"__yasst-followsingle\\\" href=\\\"twitter:/follow/'+u+'\\\">Follow</a>';e.parentNode.parentNode.insertBefore(l,e.parentNode);} else { e=i.getElementsByClassName('follow-actions');for(b=0;b<e.length;b++) {var u=e[b].parentNode.parentNode.className;u=u.substr(u.lastIndexOf(' ')+6);var l=document.createElement('div');var c=e[b].childNodes;for(var x=0;x<c.length;x++) {if (c[x].nodeName=='FORM') {var d=c[x].action.substr(c[x].action.lastIndexOf('/')+1);var f=c[x].firstChild.childNodes;l.innerHTML='<a class=\\\"__yasst-follow\\\" href=\\\"twitter:/follow/'+u+'\\\">Follow</a>';for(var y=0;y<f.length;y++) {if(f[y].nodeName=='INPUT'&&f[y].type=='submit') {f[y].parentNode.insertBefore(l,f[y]);}}}}}}}__yasst();"));
web->setEnabled(true);
//frame->setScrollPosition(QPoint(0,0));
//QTimer::singleShot(1000,this,SLOT(resetScroll()));
}
}
示例11: handleUnsupportedContent
void WebPage::handleUnsupportedContent(QNetworkReply *reply)
{
if (reply->error() == QNetworkReply::NoError) {
if (reply->header(QNetworkRequest::ContentTypeHeader).isValid())
qDebug() << "download it";
new OpDownloader(reply);
return;
}
if (reply->error() == QNetworkReply::ProtocolUnknownError) {
// we currently don't support protocol other than http(s):// and file://
// return;
}
//display notfound
if (reply->url().isEmpty())
return;
QFile file(QLatin1String(":/notfound.html"));
bool isOpened = file.open(QIODevice::ReadOnly);
Q_ASSERT(isOpened);
QString title = ("HTTP 404 Not Found");
QString html = QString(QLatin1String(file.readAll()));
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());
}
}
示例12: slotFrameLoadFinished
void KWebKitPart::slotFrameLoadFinished(bool ok)
{
QWebFrame* frame = (sender() ? qobject_cast<QWebFrame*>(sender()) : page()->mainFrame());
if (ok) {
const QUrl currentUrl (frame->baseUrl().resolved(frame->url()));
// kDebug() << "mainframe:" << m_webView->page()->mainFrame() << "frame:" << sender();
// kDebug() << "url:" << frame->url() << "base url:" << frame->baseUrl() << "request url:" << frame->requestedUrl();
if (currentUrl != *globalBlankUrl) {
m_hasCachedFormData = false;
if (WebKitSettings::self()->isNonPasswordStorableSite(currentUrl.host())) {
addWalletStatusBarIcon();
} else {
// Attempt to fill the web form...
KWebWallet *webWallet = page() ? page()->wallet() : 0;
if (webWallet) {
webWallet->fillFormData(frame, false);
}
}
}
}
}
示例13: handleUnsupportedContent
void WBWebPage::handleUnsupportedContent(QNetworkReply *reply)
{
if(reply->url().scheme() == "mailto")
{
bool result = QDesktopServices::openUrl(reply->url());
if (result)
return;
}
QString contentType = reply->header(QNetworkRequest::ContentTypeHeader).toString();
bool isPDF = (contentType == "application/pdf");
// Delete this big "if (isPDF)" block to get the pdf directly inside the browser
if (isPDF)
{
QMessageBox messageBox(mainWindow());
messageBox.setText(tr("Download PDF Document: would you prefer to download the PDF file or add it to the current Sankore document?"));
messageBox.addButton(tr("Download"), QMessageBox::AcceptRole);
QAbstractButton *addButton =
messageBox.addButton(tr("Add to Current Document"), QMessageBox::AcceptRole);
messageBox.exec();
if (messageBox.clickedButton() == addButton)
{
UBApplication::applicationController->showBoard();
UBApplication::boardController->downloadURL(reply->request().url());
return;
}
else
{
isPDF = false;
}
}
if (!isPDF && reply->error() == QNetworkReply::NoError)
{
if(contentType == "application/widget")
WBBrowserWindow::downloadManager()->handleUnsupportedContent(reply,false, UBSettings::settings()->uniboardGipLibraryDirectory());
else
WBBrowserWindow::downloadManager()->handleUnsupportedContent(reply);
return;
}
QFile file;
file.setFileName(isPDF ? QLatin1String(":/webbrowser/object-wrapper.html") : QLatin1String(":/webbrowser/notfound.html"));
bool isOpened = file.open(QIODevice::ReadOnly);
Q_ASSERT(isOpened);
QString html;
if (isPDF)
{
html = QString(QLatin1String(file.readAll()))
.arg(tr("PDF"))
.arg("application/x-ub-pdf")
.arg(reply->url().toString());
}
else
{
QString title = tr("Error loading page: %1").arg(reply->url().toString());
html = QString(QLatin1String(file.readAll()))
.arg(title)
.arg(reply->errorString())
.arg(reply->url().toString());
}
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 (mLoadingUrl == reply->url())
{
mainFrame()->setHtml(html, reply->url());
}
}