本文整理汇总了C++中QWebElementCollection::count方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebElementCollection::count方法的具体用法?C++ QWebElementCollection::count怎么用?C++ QWebElementCollection::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebElementCollection
的用法示例。
在下文中一共展示了QWebElementCollection::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LocationBarPopup
RSSWidget::RSSWidget(WebView* view, QWidget* parent)
: LocationBarPopup(parent)
, ui(new Ui::RSSWidget)
, m_view(view)
{
ui->setupUi(this);
QWebEngineFrame* frame = m_view->page()->mainFrame();
QWebElementCollection links = frame->findAllElements("link[type=\"application/rss+xml\"]");
// Make sure RSS feeds fit into a window, in case there is a lot of feeds from one page
// See #906
int cols = links.count() / 10 == 0 ? 1 : links.count() / 10;
int row = 0;
for (int i = 0; i < links.count(); i++) {
QWebElement element = links.at(i);
QString title = element.attribute("title");
const QUrl url = QUrl::fromEncoded(element.attribute("href").toUtf8());
if (url.isEmpty()) {
continue;
}
if (title.isEmpty()) {
title = tr("Untitled feed");
}
QPushButton* button = new QPushButton(this);
button->setIcon(QIcon(":icons/other/feed.png"));
button->setStyleSheet("text-align:left");
button->setText(title);
button->setProperty("rss-url", url);
button->setProperty("rss-title", title);
if (!isRssFeedAlreadyStored(url)) {
button->setFlat(true);
button->setToolTip(url.toString());
}
else {
button->setFlat(false);
button->setEnabled(false);
button->setToolTip(tr("You already have this feed."));
}
int pos = i % cols > 0 ? (i % cols) * 2 : 0;
ui->gridLayout->addWidget(button, row, pos);
connect(button, SIGNAL(clicked()), this, SLOT(addRss()));
if (i % cols == cols - 1) {
row++;
}
}
}
示例2: loadFinished
void Browser::loadFinished(bool ok) {
QUrl current_url(page->currentFrame()->baseUrl());
// events trottling
if (current_url == this->last_url)
{
qDebug() << this << QString("%1, loadFinished trottled.").arg(QDateTime::currentDateTime().toTime_t());
return;
}
this->last_url = current_url;
qDebug() << this << QString("%1, '%2', %3 ms.").arg(QDateTime::currentDateTime().toTime_t()).arg(current_url.toString()).arg(page_load_time.elapsed());
if (!ok) {
emit(errorHappened(page_load_time.elapsed(), page->currentFrame()->baseUrl()));
restartTest(QString("its not ok, something wrong happened! (possibly 500) URL: %1").arg(page->currentFrame()->baseUrl().toString()));
return;
}
QWebElement document= page->currentFrame()->documentElement();
if (page->currentFrame()->baseUrl().host() != base_url.host())
{
restartTest("We've got outside the test site. Restarting.");
return;
}
QWebElementCollection collection = document.findAll("a[href]");
QWebElement link; QString link_href;
if (collection.count() == 0)
{
restartTest("No links found on page. Restarting.");
return;
}
// Ignoring javascript and empty links
do
{
link = collection.at(qrand()%collection.count());
link_href = link.attribute("href");
}
while ((link_href.count() == 0) || (link_href.at(0) == '#') || (link_href.contains("javascript:;")));
emit(pageLoaded(page_load_time.elapsed(), page->currentFrame()->baseUrl()));
link.evaluateJavaScript("var evObj = document.createEvent('MouseEvents');evObj.initEvent( 'click', true, true );this.dispatchEvent(evObj);");
page_load_time.start();
timeout_countdown->start();
}
示例3: QFrame
RSSDetectionWidget::RSSDetectionWidget(WebView* view, QWidget* parent)
: QFrame(parent, Qt::Popup)
, view_(view)
{
setAttribute(Qt::WA_DeleteOnClose);
setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
setLineWidth(1);
setMidLineWidth(2);
gridLayout_ = new QGridLayout(this);
gridLayout_->setMargin(5);
gridLayout_->setSpacing(5);
QWebFrame* frame = view_->page()->mainFrame();
QWebElementCollection links = frame->findAllElements("link[type=\"application/rss+xml\"]");
int cols = links.count() / 10 == 0 ? 1 : links.count() / 10;
int row = 0;
for (int i = 0; i < links.count(); i++) {
QWebElement element = links.at(i);
QString title = element.attribute("title");
const QUrl url = QUrl::fromEncoded(element.attribute("href").toUtf8());
if (url.isEmpty()) {
continue;
}
if (title.isEmpty()) {
title = tr("Untitled feed");
}
QPushButton* button = new QPushButton(this);
button->setStyleSheet("QPushButton {text-align:left; border: none; padding: 0px;}"
"QPushButton:hover {color: #1155CC;}");
button->setCursor(Qt::PointingHandCursor);
button->setText(title);
button->setToolTip(url.toString());
button->setProperty("rss-url", url);
button->setProperty("rss-title", title);
int pos = i % cols > 0 ? (i % cols) * 2 : 0;
gridLayout_->addWidget(button, row, pos);
connect(button, SIGNAL(clicked()), this, SLOT(addRss()));
if (i % cols == cols - 1) {
row++;
}
}
}
示例4: updateBlockedPageElements
void QtWebKitWebPage::updateBlockedPageElements(const QStringList domainList, const bool isException)
{
for (int i = 0; i < domainList.count(); ++i)
{
const QList<QString> exceptionList = isException ? ContentBlockingManager::getHidingRulesExceptions().values(domainList.at(i)) : ContentBlockingManager::getSpecificDomainHidingRules().values(domainList.at(i));
for (int j = 0; j < exceptionList.count(); ++j)
{
const QWebElementCollection elements = mainFrame()->documentElement().findAll(exceptionList.at(j));
for (int k = 0; k < elements.count(); ++k)
{
QWebElement element = elements.at(k);
if (element.isNull())
{
continue;
}
if (isException)
{
element.setStyleProperty(QLatin1String("display"), QLatin1String("block"));
}
else
{
element.removeFromDocument();
}
}
}
}
}
示例5: parseSearchProductPage
//void ArestShopPlugin::SinglePageFound()
//{
//#ifdef USE_WEBKIT
// QWebFrame * ptrFrame = getWebPage()->mainFrame();
// parseProductPage(m_stCompData);
// m_stCompData.strCompURL = ptrFrame->url().toString();
// emit priceSearchedFinished(m_stCompData);
// productFoundFinish();
//#endif
//};
void ArestShopPlugin::parseSearchProductPage(SearchResult & stResult,bool & bNextPage)
{
//run XML search page parse
bNextPage=false;
#ifdef USE_WEBKIT
QWebFrame * ptrFrame = getWebPage()->mainFrame();
//////////////////////////////////////////////////////////////////////////
QWebElementCollection tableProdRows = ptrFrame->findAllElements("table[class=pricelist]");
for(int iIndex=0;iIndex<tableProdRows.count();++iIndex)
{
QWebElement prodNameHeader = tableProdRows.at(iIndex).findFirst("td[class=nazwa]");
if (prodNameHeader.isNull())
continue;
QWebElement productLink = prodNameHeader.findFirst("a");
QUrl stProductURL = productLink.attribute("href");
//////////////////////////////////////////////////////////////////////////
QString strName = productLink.toPlainText();
stResult.insert(std::make_pair(strName,stProductURL));
}
//////////////////////////////////////////////////////////////////////////
QWebElement tablePageNavi = ptrFrame->findFirstElement("li[class=next]");
if (tablePageNavi.isNull())
{
bNextPage=false;
return;
}
bNextPage=true;
#endif
stResult.insert(Arest::mSearchResult.begin(),Arest::mSearchResult.end());
bNextPage=m_bLoadNextPage;
}
示例6: hasRSSInfo
bool WebTab::hasRSSInfo()
{
QWebElementCollection col = page()->mainFrame()->findAllElements("link[type=\"application/rss+xml\"]");
col.append(page()->mainFrame()->findAllElements("link[type=\"application/atom+xml\"]"));
if (col.count() != 0)
return true;
return false;
}
示例7: isNotFoundPage
bool ArestShopPlugin::isNotFoundPage()
{
#ifdef USE_WEBKIT
QWebFrame * ptrFrame = getWebPage()->mainFrame();
QWebElementCollection notFoundPage = ptrFrame->findAllElements("div[class=searchfailed]");
if (notFoundPage.count())
return true;
#endif
return false;
}
示例8: isSingleProductPage
bool ArestShopPlugin::isSingleProductPage()
{
#ifdef USE_WEBKIT
QWebFrame * ptrFrame = getWebPage()->mainFrame();
QWebElementCollection productPage = ptrFrame->findAllElements("h1[class=nazwatowaru]");
if (productPage.count())
return true;
#endif
return false;
}
示例9: setTargetBlank
void PhpWebView::setTargetBlank()
{
QWebElementCollection coll = page()->mainFrame()->documentElement().findAll("a");
for (int i=0; i<coll.count(); i++)
coll.at(i).setAttribute("target", "_blank");
QWebElementCollection coll2 = page()->mainFrame()->documentElement().findAll("form");
for (int i=0; i<coll2.count(); i++)
coll2.at(i).setAttribute("target", "_blank");
}
示例10: render
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++;
}
示例11: run
void HtmlThread::run()
{
Helper::Download(this->url);
QWebElement root;
QString flag("False");
emit this->ParseHtml(this->getUrl(),root,flag);
while("True"==flag){break;}
QWebElementCollection items;
items = root.findAll("table");
qDebug()<<items.count();
}
示例12: SIPLong_FromLong
static PyObject *meth_QWebElementCollection_count(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QWebElementCollection *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QWebElementCollection, &sipCpp))
{
int sipRes;
Py_BEGIN_ALLOW_THREADS
sipRes = sipCpp->count();
Py_END_ALLOW_THREADS
return SIPLong_FromLong(sipRes);
}
}
示例13: moveTemplates
void HtmlExtractor::moveTemplates(const QString &path)
{
MakeDirectory(path);
QDir dir(path);
QWebElementCollection elements = getDocument().findAll("[type=\"text/template\"]");
if(elements.count())
{
for(QWebElementCollection::iterator it = elements.begin(), end=elements.end(); it!=end; ++it)
{
QWebElement element = *it;
QString filename = element.attribute("id").replace("_tpl",".tpl");
qDebug()<<"moving element : "<<filename;
move(element, dir.filePath(filename), false);
}
}
else
{
qDebug()<<"no element found";
}
}
示例14: setRadioCheckedProperty
void MarbleLegendBrowser::setRadioCheckedProperty( const QString& value, const QString& name , bool checked )
{
#ifndef MARBLE_NO_WEBKIT
QWebElement box = page()->mainFrame()->findFirstElement("input[value="+value+']');
QWebElementCollection boxes = page()->mainFrame()->findAllElements("input[name="+name+']');
QString currentValue="";
for(int i=0; i<boxes.count(); ++i) {
currentValue = boxes.at(i).attribute("value");
d->m_checkBoxMap[currentValue]=false;
emit toggledShowProperty( currentValue, false );
}
if (!box.isNull()) {
if (checked != d->m_checkBoxMap[value]) {
d->m_checkBoxMap[value] = checked;
emit toggledShowProperty( value, checked );
}
}
update();
#endif
}
示例15: processElement
void HtmlBookmarksImporter::processElement(const QWebElement &element)
{
if (element.tagName().toLower() == QLatin1String("h3"))
{
BookmarksItem *bookmark = BookmarksManager::addBookmark(BookmarksModel::FolderBookmark, QUrl(), element.toPlainText(), getCurrentFolder());
const QString keyword = element.attribute(QLatin1String("SHORTCUTURL"));
if (!BookmarksManager::hasKeyword(keyword))
{
bookmark->setData(keyword, BookmarksModel::KeywordRole);
}
if (!element.attribute(QLatin1String("ADD_DATE")).isEmpty())
{
const QDateTime time = QDateTime::fromTime_t(element.attribute(QLatin1String("ADD_DATE")).toUInt());
bookmark->setData(time, BookmarksModel::TimeAddedRole);
bookmark->setData(time, BookmarksModel::TimeModifiedRole);
}
setCurrentFolder(bookmark);
}
else if (element.tagName().toLower() == QLatin1String("a"))
{
const QUrl url(element.attribute(QLatin1String("href")));
if (!allowDuplicates() && BookmarksManager::hasBookmark(url))
{
return;
}
BookmarksItem *bookmark = BookmarksManager::addBookmark(BookmarksModel::UrlBookmark, url, element.toPlainText(), getCurrentFolder());
const QString keyword = element.attribute(QLatin1String("SHORTCUTURL"));
if (!BookmarksManager::hasKeyword(keyword))
{
bookmark->setData(keyword, BookmarksModel::KeywordRole);
}
if (element.parent().nextSibling().tagName().toLower() == QLatin1String("dd"))
{
bookmark->setData(element.parent().nextSibling().toPlainText(), BookmarksModel::DescriptionRole);
}
if (!element.attribute(QLatin1String("ADD_DATE")).isEmpty())
{
bookmark->setData(QDateTime::fromTime_t(element.attribute(QLatin1String("ADD_DATE")).toUInt()), BookmarksModel::TimeAddedRole);
}
if (!element.attribute(QLatin1String("LAST_MODIFIED")).isEmpty())
{
bookmark->setData(QDateTime::fromTime_t(element.attribute(QLatin1String("LAST_MODIFIED")).toUInt()), BookmarksModel::TimeModifiedRole);
}
if (!element.attribute(QLatin1String("LAST_VISITED")).isEmpty())
{
bookmark->setData(QDateTime::fromTime_t(element.attribute(QLatin1String("LAST_VISITED")).toUInt()), BookmarksModel::TimeVisitedRole);
}
}
else if (element.tagName().toLower() == QLatin1String("hr"))
{
BookmarksManager::addBookmark(BookmarksModel::SeparatorBookmark, QUrl(), QString(), getCurrentFolder());
}
const QWebElementCollection descendants = element.findAll(QLatin1String("*"));
for (int i = 0; i < descendants.count(); ++i)
{
if (descendants.at(i).parent() == element)
{
processElement(descendants.at(i));
}
}
if (element.tagName().toLower() == QLatin1String("dl"))
{
goToParent();
}
}