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


C++ QWebElement类代码示例

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


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

示例1: id

bool HistoryChatView::onContextMenu(ChatView *view, QMenu *menu, const QWebHitTestResult &result)
{
  ChatId id(view->id());
  if (id.type() != ChatId::ChannelId && id.type() != ChatId::UserId)
    return false;

  const QWebElement block = result.enclosingBlockElement();
  if (!block.hasClass("blocks") || block.hasClass("removed"))
    return false;

  const QWebElement container = block.parent();
  const qint64 mdate          = container.attribute(LS("data-mdate")).toLongLong();

  if (!mdate)
    return false;

  id.init(container.attribute(LS("id")).toLatin1());
  id.setDate(mdate);
  if (id.type() != ChatId::MessageId)
    return false;

  const int permissions = this->permissions(HistoryDB::get(id));
  if (permissions == NoPermissions)
    return false;

  if (permissions & Remove) {
    QVariantList data;
    data << view->id() << (id.hasOid() ? ChatId::toBase32(id.oid().byteArray()) : id.toString());

    menu->insertAction(menu->actions().first(), removeAction(data));
  }
  return true;
}
开发者ID:youngdev,项目名称:schat,代码行数:33,代码来源:HistoryChatView.cpp

示例2: adjust_title

void MainWindow::finished_loading(bool ok)
{
	if(!ok)
std::cout << "LOAD FINISH NOT OK!\n\n";
	QString output;
	QWebElement body;
	progress = 100;
	adjust_title();
	QWebFrame *frame = uimw->webView->page()->mainFrame();
	QWebElement document = frame->documentElement();
	QWebElement element = document.firstChild();
	while(!element.isNull())
	{
		if(element.tagName() == "BODY")
		{
			output = element.toInnerXml();
			if(output == "ok\n")
			{
				QNetworkCookieJar *cj = uimw->webView->page()->networkAccessManager()->cookieJar();
				QList<QNetworkCookie> cookies = cj->cookiesForUrl(testauth);
				for(QList<QNetworkCookie>::const_iterator i = cookies.begin() ; i != cookies.end() ; i++ )
				{
					std::cout << "Set-Cookie: ";
					QByteArray ba = i->toRawForm();
					std::cout.write(ba.data(), ba.count());
					std::cout << "\r\n";
				}
				exit(0);
			}
		}
		element = element.nextSibling();
	}
	this->show();
}
开发者ID:EMSL-MSC,项目名称:pacifica-auth,代码行数:34,代码来源:mainwindow.cpp

示例3: page

void PmrWindowWidget::filter(const QString &pFilter)
{
    // Filter our list of exposures and remove any duplicates (they will be
    // 'reintroduced' in the next step)

    QStringList filteredExposureNames = mExposureNames.filter(QRegularExpression(pFilter, QRegularExpression::CaseInsensitiveOption));

    mNumberOfFilteredExposures = filteredExposureNames.count();

    filteredExposureNames.removeDuplicates();

    // Update our message and show/hide the relevant exposures

    page()->mainFrame()->documentElement().findFirst("p[id=message]").setInnerXml(message());

    QWebElement trElement = page()->mainFrame()->documentElement().findFirst(QString("tbody[id=exposures]")).firstChild();
    QWebElement ulElement;

    for (int i = 0, iMax = mExposureNames.count(); i < iMax; ++i) {
        if (mExposureDisplayed[i] != filteredExposureNames.contains(mExposureNames[i])) {
            QString displayValue = mExposureDisplayed[i]?"none":"table-row";

            trElement.setStyleProperty("display", displayValue);

            ulElement = trElement.firstChild().firstChild().nextSibling();

            if (ulElement.hasClass("visible"))
                ulElement.setStyleProperty("display", displayValue);

            mExposureDisplayed[i] = !mExposureDisplayed[i];
        }

        trElement = trElement.nextSibling();
    }
}
开发者ID:fethio,项目名称:opencor,代码行数:35,代码来源:pmrwindowwidget.cpp

示例4: getDuelResult

FightBox MWBotWin::getDuelResult() {
	FightBox res;
	int mylife;
	int enlife;
	QWebElement elm;
	res.enemy = getStat("div.fighter2","td.fighter2-cell");
	clickElement("i.icon.icon-forward");				// forward button
	mylife = frm->findFirstElement("span#fighter1-life").toPlainText().split("/").first().trimmed().toInt();
	enlife = frm->findFirstElement("span#fighter2-life").toPlainText().split("/").first().trimmed().toInt();
	res.result = (mylife > 0) ? 1 : ((enlife > 0) ? 0 : 2);		// duel result (0,1,2 = lose,win,draw)
	res.items = getDuelResultMain();
	elm = frm->findFirstElement("div.backlink div.button div.c");
	if (!elm.isNull()) {
		clickElement(elm);
	}
	res.items.append(getDuelResultExtra());
	return res;
}
开发者ID:samstyle,项目名称:MWBot,代码行数:18,代码来源:results.cpp

示例5: setNumConnections

void ShadowGUI::setNumConnections(int count)
{
    QWebElement connectionsIcon = documentFrame->findFirstElement("#connectionsIcon");

    QString icon;
    switch(count)
    {
    case 0:          icon = "qrc:///icons/connect_0"; break;
    case 1: case 2:  icon = "qrc:///icons/connect_1"; break;
    case 3: case 4:  icon = "qrc:///icons/connect_2"; break;
    case 5: case 6:  icon = "qrc:///icons/connect_3"; break;
    case 7: case 8:  icon = "qrc:///icons/connect_4"; break;
    case 9: case 10: icon = "qrc:///icons/connect_5"; break;
    default:         icon = "qrc:///icons/connect_6"; break;
    }
    connectionsIcon.setAttribute("src", icon);
    connectionsIcon.setAttribute("title", tr("%n active connection(s) to ZirkCoin network", "", count));
}
开发者ID:axelxod,项目名称:ZirkCoin,代码行数:18,代码来源:shadowgui.cpp

示例6: foreach

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;
}
开发者ID:WizLxn,项目名称:MAssistant,代码行数:18,代码来源:CWebNewsLoader.cpp

示例7: getGroupResult

FightBox MWBotWin::getGroupResult() {
	FightBox res;
	QWebElement elm;
	QString str;
	elm = frm->findFirstElement("form#fightGroupForm h3 div.group2");
	str = elm.toPlainText();
	res.enemy.name = str.split("(").first().trimmed();
	res.enemy.type = elm.findFirst("i").attribute("class");
	res.enemy.level = -1;
	res.result = str.contains("(0/") ? 1 : 0;
	res.items = getGroupResultMain();
	elm = frm->findFirstElement("td.log div.result div.button div.c");
	if (!elm.isNull()) {
		clickElement(elm);
	}
	res.items.append(getDuelResultExtra());
	return res;
}
开发者ID:samstyle,项目名称:MWBot,代码行数:18,代码来源:results.cpp

示例8: while

QTreeWidgetItem* XPathInspector::findTreeItemAndSelect(const QWebElement & elem)
{
	QList<QWebElement> patharr;
	QWebElement current = elem;
	while (!current.isNull())
	{
		patharr.prepend(current);
		current = current.parent();
	}

	QTreeWidgetItem *topitem = NULL;
	for (int i=0; i<tree->topLevelItemCount(); i++)
	{
		QTreeWidgetItem *item = tree->topLevelItem(i);
		QWebElement node = item->data(0, Qt::UserRole).value<QWebElement>();
		if (node == patharr.at(0))
		{
			tree->expandItem(item);
			topitem = item;
			break;
		}
	}

	for (int i=1; i<patharr.count(); i++)	
	{
		if (topitem != NULL)
		{
			for (int j=0; j<topitem->childCount(); j++)
			{
				QWebElement node = topitem->child(j)->data(0, Qt::UserRole).value<QWebElement>();
				if (patharr.at(i) == node)
				{
					topitem = topitem->child(j);
					tree->expandItem(topitem);
					break;
				}
			}
		}
	}

	topitem->setSelected(true);
	return topitem;
}
开发者ID:scraperlab,项目名称:browserext,代码行数:43,代码来源:xpathinspector.cpp

示例9: fit

//static
bool Page_Login::fit(const QWebElement& doc) {
//    qDebug("* CHECK Page_Login");
    QWebElement loginForm = doc.findFirst("FORM[id=loginForm]");
    if (loginForm.isNull()) {
//        qDebug("Page_Login does not fit (has no loginForm)");
        return false;
    }
    QWebElement do_cmd = loginForm.findFirst("INPUT[name=do_cmd]");
    if (do_cmd.isNull()) {
//        qDebug("Page_Login does not fit (has no do_cmd)");
        return false;
    }
    if (do_cmd.attribute("value") != "login") {
//        qDebug("Page_Login does not fit (do_cmd != login)");
        return false;
    }
//    qDebug("Page_Login fits");
    return true;
}
开发者ID:gourytch,项目名称:bezzabot,代码行数:20,代码来源:page_login.cpp

示例10: qCritical

void LyricsManiaAPI::onGetLyricPageResult()
{
    QNetworkReply* reply = qobject_cast<QNetworkReply*>(QObject::sender());

    bool found = false;
    Lyric* lyric = 0;

    if (reply->error() != QNetworkReply::NoError) {
        qCritical() << "Cannot fetch lyric";
    } else {
        QWebPage page;
        page.settings()->setAttribute(QWebSettings::AutoLoadImages, false);
        page.settings()->setAttribute(QWebSettings::JavascriptEnabled, false);
        page.mainFrame()->setHtml(reply->readAll());

        QWebElement lyricbox = page.mainFrame()->findFirstElement("div[class=lyrics-body]");

        if (lyricbox.isNull()) {
            qCritical() << "Cannot find lyric text in HTML page";
        } else {
            // Remove the video div
            lyricbox.findFirst(QStringLiteral("div")).removeFromDocument();
            // Remove the song title
            lyricbox.findFirst(QStringLiteral("strong")).removeFromDocument();

            lyric = lyrics.take(reply);

            if (!lyric) {
                qCritical() << "Got an invalid lyric object!";
            } else {
                lyric->setText(lyricbox.toPlainText());

                found = true;
            }
        }
    }

    qDebug() << "Lyric found:" << found;
    Q_EMIT lyricFetched(lyric, found);

    reply->deleteLater();
}
开发者ID:Quent-in,项目名称:harbour-Lyrics,代码行数:42,代码来源:lyricsmaniaapi.cpp

示例11: qDebug

bool MainWindow::disableSelection()
{
    if (mainSettings->value("view/disable_selection").toBool()) {
        qDebug("Try to disable text selection...");

        // Then webkit loads page and it's "empty" - empty html DOM loaded...
        // So we wait before real page DOM loaded...
        QWebElement bodyElem = view->page()->mainFrame()->findFirstElement("body");
        if (!bodyElem.isNull() && !bodyElem.toInnerXml().trimmed().isEmpty()) {
            QWebElement headElem = view->page()->mainFrame()->findFirstElement("head");
            if (headElem.isNull() || headElem.toInnerXml().trimmed().isEmpty()) {
                qDebug("... html head not loaded ... wait...");
                return false;
            }

            //qDebug() << "... head element content:\n" << headElem.toInnerXml();

            // http://stackoverflow.com/a/5313735
            QString content;
            content = "<style type=\"text/css\">\n";
            content += "body, div, p, span, h1, h2, h3, h4, h5, h6, caption, td, li, dt, dd {\n";
            content += " -moz-user-select: none;\n";
            content += " -khtml-user-select: none;\n";
            content += " -webkit-user-select: none;\n";
            content += " user-select: none;\n";
            content += " }\n";
            content += "</style>\n";

            // Ugly hack, but it's works...
            if (!headElem.toInnerXml().contains(content)) {
                headElem.setInnerXml(headElem.toInnerXml() + content);
                qDebug("... html head loaded ... hack inserted...");
            } else {
                qDebug("... html head loaded ... hack already inserted...");
            }

            //headElem = view->page()->mainFrame()->findFirstElement("head");
            //qDebug() << "... head element content after:\n" << headElem.toInnerXml() ;

        } else {
            qDebug("... html body not loaded ... wait...");
            return false;
        }
    }

    return true;
}
开发者ID:noname007,项目名称:qt-webkit-kiosk,代码行数:47,代码来源:mainwindow.cpp

示例12: foreach

void downloader::render(QString rawHtml)
{
    currencyLoaded.clear();
    rateLoaded.clear();
    QWebFrame *mainFrame = webPage.mainFrame();
    mainFrame->setHtml(rawHtml);
    QWebElement documentElement = mainFrame->documentElement();
    QWebElementCollection elements = documentElement.findAll("#content > div:nth-child(1) > div > div.col2.pull-right.module.bottomMargin > div.moduleContent > table:nth-child(4) > tbody > tr");

    int i = 0;
    foreach (QWebElement element, elements)
    {
        currency.push_back(element.findFirst("td:nth-child(1)").toInnerXml());
        rate.push_back(element.findFirst("td:nth-child(3) > a").toInnerXml());
//        qDebug()<< currency[i+(elements.count()*downloadCount)]+"\t\t"+rate[i+(elements.count()*downloadCount)]+"\n";

        currencyLoaded.push_back(currency[i+(elements.count()*downloadCount)]);
        rateLoaded.push_back(rate[i+(elements.count()*downloadCount)]);
        i++;
    }
开发者ID:GlennVialli,项目名称:test,代码行数:20,代码来源:downloader.cpp

示例13: appendInside

/*!
    Inserts the given \a element before this element.

    If \a element is the child of another element, it is re-parented to the
    parent of this element.

    Calling this function on a null element does nothing.

    \sa appendInside(), prependInside(), appendOutside()
*/
void QWebElement::prependOutside(const QWebElement &element)
{
    if (!m_element || element.isNull())
        return;

    if (!m_element->parent())
        return;

    ExceptionCode exception = 0;
    m_element->parent()->insertBefore(element.m_element, m_element, exception);
}
开发者ID:dzip,项目名称:webkit,代码行数:21,代码来源:qwebelement.cpp

示例14: toMap

extern QVariantMap toMap(QWebElement el, QStringList css_attrs) {
    QVariantMap map;
    map["isNull"] = false;
    map["classes"] = QVariant(el.classes());
    map["tagName"] = QVariant(el.tagName());
    QRect rect = el.geometry();

    QVariantMap geo;

    geo["width"] = rect.width();
    geo["height"] = rect.height();
    geo["x"] = rect.x();
    geo["y"] = rect.y();
    map["geometry"] = QVariant(geo);

    QVariantMap attrs;
    QStringList attributes = el.attributeNames();
    foreach(QString name,attributes) {
        attrs[name] = el.attribute(name);
    }
开发者ID:jasonknight,项目名称:ichabod,代码行数:20,代码来源:helpers.cpp

示例15: isEditableElement

static bool isEditableElement(QWebPage* page)
{
    const QWebFrame* frame = (page ? page->currentFrame() : 0);
    QWebElement element = (frame ? frame->findFirstElement(QL1S(":focus")) : QWebElement());
    if (!element.isNull()) {
        const QString tagName(element.tagName());
        if (tagName.compare(QL1S("textarea"), Qt::CaseInsensitive) == 0) {
            return true;
        }
        const QString type(element.attribute(QL1S("type")).toLower());
        if (tagName.compare(QL1S("input"), Qt::CaseInsensitive) == 0
            && (type.isEmpty() || type == QL1S("text") || type == QL1S("password"))) {
            return true;
        }
        if (element.evaluateJavaScript("this.isContentEditable").toBool()) {
            return true;
        }
    }
    return false;
}
开发者ID:KDE,项目名称:kwebkitpart,代码行数:20,代码来源:webview.cpp


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