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


C++ QWebElement::findFirst方法代码示例

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


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

示例1: _loadFinished

void MainWindow::_loadFinished(bool ok)
{
    if (ok)
    {
        QString indexUrl = _appSettings.host();
        indexUrl += "index.php";

        QString pageUrl = ui->webView->url().toString();
        QWebPage* page = ui->webView->page();
        QWebFrame* frame = page->currentFrame();
        QWebElement root = frame->documentElement();
        if (!root.findFirst("#loginForm").isNull())
        {
            QWebElementCollection allInputs = root.findAll("input");
            foreach (QWebElement inputElement, allInputs)
            {
                if (inputElement.hasAttribute("name"))
                {
                    QString name = inputElement.attribute("name");
                    if (name == "username")
                    {
                        inputElement.setAttribute("value", _appSettings.user());
                    }
                    else if (name == "password")
                    {
                        inputElement.setAttribute("value", _appSettings.password());
                    }
                }
            }

            root.findFirst("input[type=submit]").evaluateJavaScript("this.click()");
        }
        else if (pageUrl == indexUrl)
开发者ID:fralik,项目名称:ZmKiosk,代码行数:33,代码来源:mainwindow.cpp

示例2: parseResult

StationScheduleItem parseResult(const QWebElement &result)
{
    StationScheduleItem item;

    QWebElement current = result.findFirst("h2");
    if (!current.isNull()) {
        item.setTrain(current.toPlainText());
    }
    parseDetailsUrl(result, item);
    current = result.findFirst("div.bloccotreno");
    parseDelayClass(current, item);
    QString rawText = current.toPlainText();
    parseTrain(rawText, item);

    qDebug() << "train:" << item.train();
    qDebug() << "delayClass:" << item.delayClass();
    qDebug() << "detailsUrl:" << item.detailsUrl();
    qDebug() << "departureStation:" << item.departureStation();
    qDebug() << "departureTime:" << item.departureTime();
    qDebug() << "arrivalStation:" << item.arrivalStation();
    qDebug() << "arrivalTime:" << item.arrivalTime();
    qDebug() << "expectedPlatform:" << item.expectedPlatform();
    qDebug() << "actualPlatform:" << item.actualPlatform();
    qDebug() << "delay:" << item.delay();
    return item;
}
开发者ID:mikelima,项目名称:quandoparte,代码行数:26,代码来源:stationschedulemodel.cpp

示例3: removeMessageLog

void lmcMessageLog::removeMessageLog(QString divClass) {
	QWebFrame* frame = page()->mainFrame();
	QWebElement document = frame->documentElement();
	QWebElement body = document.findFirst("body");
	QWebElement element = body.findFirst("div." + divClass);
	element.removeFromDocument();
}
开发者ID:j2doll,项目名称:lmc-clone,代码行数:7,代码来源:messagelog.cpp

示例4: filePermissionsChanged

void CellmlAnnotationViewMetadataNormalViewDetailsWidget::filePermissionsChanged()
{
    // Enable or disable the remove buttons for our RDF triples, depending on
    // whether the file is un/locked

    bool fileReadableAndWritable = Core::FileManager::instance()->isReadableAndWritable(mCellmlFile->fileName());
    QWebElement documentElement = mOutputOntologicalTerms->page()->mainFrame()->documentElement();

    foreach (const QString &rdfTripleInformationSha1, mRdfTripleInformationSha1s) {
        documentElement.findFirst(QString("td[id=button_%1]").arg(rdfTripleInformationSha1)).setStyleProperty("display", fileReadableAndWritable?"table-cell":"none");
        documentElement.findFirst(QString("td[id=disabledButton_%1]").arg(rdfTripleInformationSha1)).setStyleProperty("display", !fileReadableAndWritable?"table-cell":"none");
    }
开发者ID:hsorby,项目名称:opencor,代码行数:12,代码来源:cellmlannotationviewmetadatanormalviewdetailswidget.cpp

示例5: handleUnsupportedContent

void WebPage::handleUnsupportedContent(QNetworkReply* reply)
{
    if (!reply) {
        return;
    }

    const QUrl url = reply->url();

    switch (reply->error()) {
    case QNetworkReply::NoError:
        if (reply->header(QNetworkRequest::ContentTypeHeader).isValid()) {
            QString requestUrl = reply->request().url().toString(QUrl::RemoveFragment | QUrl::RemoveQuery);
            if (requestUrl.endsWith(QLatin1String(".swf"))) {
                const QWebElement docElement = mainFrame()->documentElement();
                const QWebElement object = docElement.findFirst(QString("object[src=\"%1\"]").arg(requestUrl));
                const QWebElement embed = docElement.findFirst(QString("embed[src=\"%1\"]").arg(requestUrl));

                if (!object.isNull() || !embed.isNull()) {
                    qDebug() << "WebPage::UnsupportedContent" << url << "Attempt to download flash object on site!";
                    reply->deleteLater();
                    return;
                }
            }
            DownloadManager* dManager = mApp->downloadManager();
            dManager->handleUnsupportedContent(reply, this);
            return;
        }
        // Falling unsupported content with invalid ContentTypeHeader to be handled as UnknownProtocol

    case QNetworkReply::ProtocolUnknownError: {
        if (url.scheme() == QLatin1String("file")) {
            FileSchemeHandler::handleUrl(url);
            return;
        }

        qDebug() << "WebPage::UnsupportedContent" << url << "ProtocolUnknowError";
        desktopServicesOpen(url);

        reply->deleteLater();
        return;
    }
    default:
        break;
    }

    qDebug() << "WebPage::UnsupportedContent error" << url << reply->errorString();
    reply->deleteLater();
}
开发者ID:593in,项目名称:qupzilla,代码行数:48,代码来源:webpage.cpp

示例6: 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;
}
开发者ID:T4ng10r,项目名称:ComputerComponentsShop,代码行数:43,代码来源:ArestShop.cpp

示例7: doLogin

bool Page_Login::doLogin (
        int servNo,
        const QString& login,
        const QString& password,
        bool keep) {
    Q_ASSERT(!document.isNull());
    QWebElement form = document.findFirst("FORM[id=loginForm]");
    if (form.isNull()) {
        qCritical("login form not found");
        return false;
    }
    //QWebElement
    submit = form.findFirst("INPUT[type=submit]");
    if (submit.isNull()) {
        qCritical("submit button not found");
        return false;
    }

    js_setById("server", servNo);
    js_setByName("email", login);
    js_setByName("password", password);
    if (keep) {
        js("document.getElementsByName('remember')[0].checked=true;");
    }
    qDebug("press login button");
    pressSubmit();
    return true;
}
开发者ID:gourytch,项目名称:bezzabot,代码行数:28,代码来源:page_login.cpp

示例8: 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() + "\" />");
            }
        }
    }
}
开发者ID:duckinator,项目名称:WildFox,代码行数:60,代码来源:mainwindow.cpp

示例9: appendPublicMessage

void lmcMessageLog::appendPublicMessage(QString* lpszUserId, QString* lpszUserName, QString* lpszMessage,
										QDateTime *pTime, QFont *pFont, QColor *pColor) {
	QString html = QString::null;
	bool localUser = (lpszUserId->compare(localId) == 0);

	decodeMessage(lpszMessage);

	QString fontStyle = getFontStyle(pFont, pColor, localUser);

	if(lpszUserId->compare(lastId) != 0) {
		outStyle = !outStyle;
		html = outStyle ? themeData.outMsg : themeData.inMsg;

		//	get the avatar image for this user from the cache folder
		QString filePath = participantAvatars.value(*lpszUserId);
		//	if image not found, use the default avatar image for this user
		QString iconPath = QFile::exists(filePath) ? QUrl::fromLocalFile(filePath).toString() : "qrc"AVT_DEFAULT;

		html.replace("%iconpath%", iconPath);
		html.replace("%sender%", *lpszUserName);
		html.replace("%time%", getTimeString(pTime));
		html.replace("%style%", fontStyle);
		html.replace("%message%", *lpszMessage);

		QWebFrame* frame = page()->mainFrame();
		QWebElement document = frame->documentElement();
		QWebElement body = document.findFirst("body");
		body.appendInside(html);
	} else {
		html = outStyle ? themeData.outNextMsg : themeData.inNextMsg;
		html.replace("%time%", getTimeString(pTime));
		html.replace("%style%", fontStyle);
		html.replace("%message%", *lpszMessage);

		QWebFrame* frame = page()->mainFrame();
		QWebElement document = frame->documentElement();
		QWebElement body = document.findFirst("body");
		QWebElement last = body.lastChild();
		QWebElement insert = last.findFirst("div#insert");
		insert.replace(html);
	}

	hasData = true;
}
开发者ID:j2doll,项目名称:lmc-clone,代码行数:44,代码来源:messagelog.cpp

示例10: parseDetailsUrl

static void parseDetailsUrl(const QWebElement &element, StationScheduleItem &item)
{
    if (!element.isNull()) {
        QWebElement link = element.findFirst("a");
        QString url = link.attribute("href");
        item.setDetailsUrl(url);
    } else {
        qDebug() << "link not found";
    }
}
开发者ID:mikelima,项目名称:quandoparte,代码行数:10,代码来源:stationschedulemodel.cpp

示例11: 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

示例12: onGetLyricPageResult

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

示例13: fit

bool Page_Game_Dozor_LowHealth::fit(const QWebElement& doc) {
//    qDebug("* CHECK Page_Game_Dozor_LowHealth");
    if (doc.findFirst("DIV[id=body] DIV[class=grbody]")
            .toPlainText().trimmed().startsWith(
                u8("У вас слишком мало здоровья."))) {
//        qDebug("CHECK Page_Game_Dozor_LowHealth fits");
        return true;
    }
//    qDebug("CHECK Page_Game_Dozor_LowHealth doesn't fit");
    return false;
}
开发者ID:gourytch,项目名称:bezzabot,代码行数:11,代码来源:page_game_dozor_lowhealth.cpp

示例14: sendReportUsingGitreport

/**
 * @fn sendReportUsingGitreport
 */
void GitreportModule::sendReportUsingGitreport(const QMap<QString, QString> info)
{
    if (debug) qDebug() << "[GitreportModule]" << "[sendReportUsingGitreport]";

    QWebElement document = webView->page()->mainFrame()->documentElement();
    QWebElement captchaKey = document.findFirst(QString("input#captcha"));
    QWebElement emailInput = document.findFirst(QString("input#email"));
    QWebElement textArea = document.findFirst(QString("textarea#details"));
    QWebElement usernameInput = document.findFirst(QString("input#name"));

    // input
    usernameInput.setAttribute(QString("value"), info[QString("username")]);
    emailInput.setAttribute(QString("value"), info[QString("password")]);
    textArea.setPlainText(info[QString("body")]);
    captchaKey.setAttribute(QString("value"), info[QString("captcha")]);

    // send request
    document.findFirst(QString("input[name=commit]")).evaluateJavaScript("this.click()");
    disconnect(webView, SIGNAL(loadFinished(bool)), this, SLOT(gitreportLoaded(bool)));
    disconnect(webView, SIGNAL(loadFinished(bool)), this, SLOT(gitreportFinished(bool)));
    connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(gitreportFinished(bool)));
}
开发者ID:arcan1s,项目名称:reportabug,代码行数:25,代码来源:gitreportmodule.cpp

示例15: WebChromeContainerSnippet

  ChromeSnippet *ChromeDOM::getSnippet(const QString &docElementId, QGraphicsItem* parent) {
    Q_UNUSED(parent)

    ChromeSnippet * snippet = 0;
    QWebElement doc = m_page->mainFrame()->documentElement();
    QWebElement element = doc.findFirst("#" + docElementId);
    QRect rect = element.geometry();
    //TODO: This may not be accurate since final heights may not have been computed at this point!!
    m_height += rect.height();
    
    //    qDebug() << "Snippet: ID: " << docElementId << " Owner Area: " << rect << " Element Rect: " << element.geometry();
  
    if (!rect.isNull()) {
        QString className = element.attribute("data-GinebraNativeClass", "__NO_CLASS__");
        if (className == "__NO_CLASS__") {
            if (element.attribute("data-GinebraContainer", "false") == "true") {
                snippet = new WebChromeContainerSnippet(docElementId, m_chrome, element);
                snippet->setChromeWidget(new ChromeItem(snippet));
            }
            else {
                snippet = new WebChromeSnippet(docElementId, m_chrome, element);
                m_renderer->addRenderItem((static_cast<WebChromeSnippet*> (snippet))->item());
            }
        }
        else {
            snippet = nativeSnippetForClassName(className, docElementId, element);
            //TODO: Is the following still needed?
            QGraphicsWidget * widget = snippet->widget();
            //Have snippet determine its own size when in anchor layout. Again, these will not
            //necessarily be accurate at this point.
            widget->resize(rect.width(), rect.height());
            widget->setPreferredSize(rect.width(), rect.height());
            widget->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
            //Have snippet determine its own location when NOT in anchor layout
            widget->setPos(rect.x(), rect.y());
            
        }

        QWebElement parentElem;

        if (!(parentElem = findChromeParent(element)).isNull()) {
            snippet->setParentId(parentElem.attribute("id"));
        }
        //Set auto-layout attributes
        snippet->setAnchor(element.attribute("data-GinebraAnchor", "AnchorNone"), false);
        snippet->setAnchorOffset(element.attribute("data-GinebraAnchorOffset", "0").toInt());
        snippet->setInitiallyVisible(element.attribute("data-GinebraVisible", "false") == "true");
        snippet->setHidesContent(element.attribute("data-GinebraHidesContent", "false") == "true");
    }
    return snippet;
  }
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:51,代码来源:ChromeDOM.cpp


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