本文整理汇总了C++中QWebElement::appendOutside方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebElement::appendOutside方法的具体用法?C++ QWebElement::appendOutside怎么用?C++ QWebElement::appendOutside使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebElement
的用法示例。
在下文中一共展示了QWebElement::appendOutside方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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() + "\" />");
}
}
}
}