本文整理汇总了C++中QWebElementCollection类的典型用法代码示例。如果您正苦于以下问题:C++ QWebElementCollection类的具体用法?C++ QWebElementCollection怎么用?C++ QWebElementCollection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QWebElementCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: page
void WebTab::showRSSInfo(const QPoint &pos)
{
QWebElementCollection col = page()->mainFrame()->findAllElements("link[type=\"application/rss+xml\"]");
col.append(page()->mainFrame()->findAllElements("link[type=\"application/atom+xml\"]"));
QMap<KUrl, QString> map;
foreach(const QWebElement &el, col)
{
QString urlString;
if (el.attribute("href").startsWith(QL1S("http")))
urlString = el.attribute("href");
else
{
KUrl u = url();
// NOTE
// cd() is probably better than setPath() here,
// for all those url sites just having a path
if (u.cd(el.attribute("href")))
urlString = u.toMimeDataString();
}
QString title = el.attribute("title");
if (title.isEmpty())
title = el.attribute("href");
map.insert(KUrl(urlString), title);
}
示例2: scrap
void dilbert::scrap(bool ok)
{
if (ok)
{
ui->progressBar->hide();
QWebElementCollection imgs = view->page()->mainFrame()->findAllElements("img");
QWebElement img;
if (comicid == latest || comicid == QDate(1989, 04, 16))
img = imgs.at(1);
else
img = imgs.at(2);
QString imgLink = QString("http://dilbert.com").append(img.attribute("src").toAscii().constData());
ui->webView->setUrl(QUrl(imgLink));
if (comicid == QDate(1989, 04, 16))
{
ui->prev->setEnabled(false);
}
else
{
ui->prev->setEnabled(true);
}
if (comicid == latest)
{
ui->next->setEnabled(false);
}
else
{
ui->next->setEnabled(true);
}
}
}
示例3: qDebug
void MangaherePlugin::downloadedMangaList(bool ok)
{
if(!ok)
{
qDebug() << tr("There was an error loading the manga list from host 'www.mangahere.co'.");
return;
}
//MangaList successfully downloaded, processing the HTML...
m_mangaListLoaded = true;
m_mangaList.clear();
QWebElement element = m_pPageMangaList.mainFrame()->documentElement();
QWebElementCollection collAllMangas = element.findAll(".manga_info");
qDebug() << "Sample Manga:" << collAllMangas.at(0).toPlainText() << " url(" << collAllMangas.at(0).attribute("href", "ERROR") << ")";
int i = 0;
foreach (QWebElement oneManga, collAllMangas) {
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
Manga::Simple manga;
manga.title = oneManga.toPlainText();
manga.url = oneManga.attribute("href", "ERROR");
m_mangaList << manga;
i++;
}
示例4: getWebPage
//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;
}
示例5: mainFrame
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();
}
}
}
}
}
示例6: page
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: page
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");
}
示例8: foreach
foreach (QWebElement selectField, selectFields) {
QString name = selectField.attribute(QLatin1String("name"));
int selectedIndex = selectField.evaluateJavaScript(QLatin1String("this.selectedIndex")).toInt();
if (selectedIndex == -1)
continue;
QWebElementCollection options = selectField.findAll(QLatin1String("option"));
QString value = options.at(selectedIndex).toPlainText();
searchUrl.addQueryItem(name, value);
}
示例9: 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++;
}
}
}
示例10: flag
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();
}
示例11: current_url
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();
}
示例12: 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++;
}
}
}
示例13: while
void ClickToFlash::findElement()
{
if (!loadButton_)
return;
QPoint objectPos = page_->view()->mapFromGlobal(loadButton_->mapToGlobal(loadButton_->pos()));
QWebFrame* objectFrame = page_->frameAt(objectPos);
QWebHitTestResult hitResult;
QWebElement hitElement;
if (objectFrame) {
hitResult = objectFrame->hitTestContent(objectPos);
hitElement = hitResult.element();
}
if (!hitElement.isNull() && (hitElement.tagName().compare("embed", Qt::CaseInsensitive) == 0 ||
hitElement.tagName().compare("object", Qt::CaseInsensitive) == 0)) {
element_ = hitElement;
return;
}
// HitTestResult failed, trying to find element by src
// attribute in elements at all frames on page (less accurate)
QList<QWebFrame*> frames;
frames.append(objectFrame);
frames.append(page_->mainFrame());
while (!frames.isEmpty()) {
QWebFrame* frame = frames.takeFirst();
if (!frame) {
continue;
}
QWebElement docElement = frame->documentElement();
QWebElementCollection elements;
elements.append(docElement.findAll(QLatin1String("embed")));
elements.append(docElement.findAll(QLatin1String("object")));
foreach (const QWebElement &element, elements) {
if (!checkElement(element) && !checkUrlOnElement(element)) {
continue;
}
element_ = element;
return;
}
frames += frame->childFrames();
}
}
示例14: bufreset
void tdRenderer::render(QByteArray ba)
{
bufreset(m_buffer);
QWebElement element = m_body.findFirst(".__tmp__");
const char *data = ba.data();
uint beg = 0;
size_t e = ba.size();
int prevsize = 0;
int pos = m_fframe;
while (beg < e) {
const char *offs = data + beg;
int n = td_markdown_render(m_buffer, (const uint8_t *) offs,
e - beg, m_markdown);
QByteArray bytes((const char *) m_buffer->data + prevsize, m_buffer->size - prevsize);
m_sizes.insert(pos, n);
m_indices.insert(pos++, m_index);
if (m_pants) {
bufreset(m_tmpbuffer);
sdhtml_smartypants(m_tmpbuffer, (const uint8_t *) bytes.constData(), bytes.size());
QByteArray pants((const char *) m_tmpbuffer->data, m_tmpbuffer->size);
element.appendInside(pants);
} else {
element.appendInside(bytes);
}
QWebElementCollection children = element.findAll("*");
QString klassName = "__" % QString::number(m_index++) % "__";
QWebElementCollection::const_iterator i = children.constBegin();
for (; i != children.constEnd(); ++i) {
QWebElement e = *i;
e.addClass(klassName);
if (!e.parent().hasClass(klassName))
element.prependOutside(e.takeFromDocument());
}
if (m_body.findFirst("." % klassName).isNull())
element.prependOutside("<span class=\"" % klassName % "\"></span>");
beg += n;
prevsize = m_buffer->size;
}
element.takeFromDocument();
}
示例15: 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);
}
}