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


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

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


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

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

示例2: loadFinished

void AuthenticationDialog::loadFinished()
{
//     Q_D(AuthenticationDialog);
    QUrl url = d->webView->url();

    if (url.host() == "www.facebook.com" && url.path() == "/login.php") {
        if (d->username.isEmpty() && d->password.isEmpty()) {
            return;
        }

        QWebFrame *frame = d->webView->page()->mainFrame();
        if (!d->username.isEmpty()) {
            QWebElement email = frame->findFirstElement("input#email");
            if (!email.isNull()) {
                email.setAttribute("value", d->username);
            }
        }

        if (!d->password.isEmpty()) {
            QWebElement passd = frame->findFirstElement("input#pass");
            if (!passd.isNull()) {
                passd.setAttribute("value", d->password);
            }
        }
        return;
    }
}
开发者ID:KDE,项目名称:libkfbapi,代码行数:27,代码来源:authenticationdialog.cpp

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

示例4: finished_loading

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

示例5: mousePressEvent

			void KinotifyWidget::mousePressEvent (QMouseEvent *event)
			{
				const QWebHitTestResult& r = page ()->mainFrame ()->hitTestContent (event->pos ());
				if (!r.linkUrl ().isEmpty ())
				{
					QWebView::mousePressEvent (event);
					return;
				}

				QWebElement elem = r.element ();
				if (elem.isNull () || elem.attribute ("type") != "button")
				{
					disconnect (CheckTimer_,
							SIGNAL (timeout ()),
							this,
							SIGNAL (checkNotificationQueue ()));

					disconnect (&Machine_,
							SIGNAL (finished ()),
							this,
							SLOT (closeNotification ()));

					emit checkNotificationQueue ();
					closeNotification ();
				}
				else
					QWebView::mousePressEvent (event);
			}
开发者ID:nobodyzzz,项目名称:leechcraft,代码行数:28,代码来源:kinotifywidget.cpp

示例6: 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();
				}
			}
		}
	}
}
开发者ID:mboevink,项目名称:otter,代码行数:31,代码来源:QtWebKitWebPage.cpp

示例7: SLOT

int PhpWebView::click2(QWebElement elem, bool samewnd)
{
	if (elem.isNull())
		return 0;

	if (samewnd)
		elem.removeAttribute("target");

	QEventLoop loop;
	isNewViewCreated = false;
	isNewViewBegin = false;
	
	QString js = "var e = document.createEvent('MouseEvents');";
	//js += "e.initEvent( 'click', true, true );";
    js += "e.initMouseEvent( 'click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);";
    js += "this.dispatchEvent(e);";
	elem.evaluateJavaScript(js);
	
	QTimer::singleShot(1000, &loop, SLOT(quit()));
	loop.exec();
	
	while (browser && isNewViewBegin && !isNewViewCreated)
		loop.processEvents();

	return 1;
}
开发者ID:scraperlab,项目名称:browserext,代码行数:26,代码来源:phpwebview.cpp

示例8: loginPage

void GoogleChat::loginPage(bool ok) {
    QString location = form.webView->url().toString();
    if (!ok) {
        if (location.indexOf("CheckCookie"))
            return;
        showError("Service unavailable");
    } else {
        // check for any error message

        QWebElement  e = document().findFirst(".errormsg");
        if (e.isNull()) {
            form.stackedWidget->setCurrentIndex(2);
            QTimer::singleShot(500, this, SLOT(hideElements()));
            return;
        }

       QString err = "Unknown login failure.";
       const QString errorMessage = e.toPlainText();
        if (!errorMessage.isEmpty()) {
            err = errorMessage;
            err = err.simplified();
        }
        showError(err);
    }
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:25,代码来源:googlechat.cpp

示例9: encloseWith

/*!
    Encloses this element with \a element. This element becomes the child of
    the deepest descendant within \a element.

    \sa replace()
*/
void QWebElement::encloseWith(const QWebElement &element)
{
    if (!m_element || element.isNull())
        return;

    RefPtr<Node> insertionPoint = findInsertionPoint(element.m_element);

    if (!insertionPoint)
        return;

    // Keep reference to these two nodes before pulling out this element and
    // wrapping it in the fragment. The reason for doing it in this order is
    // that once the fragment has been added to the document it is empty, so
    // we no longer have access to the nodes it contained.
    Node* parentNode = m_element->parent();
    Node* siblingNode = m_element->nextSibling();

    ExceptionCode exception = 0;
    insertionPoint->appendChild(m_element, exception);

    if (!siblingNode)
        parentNode->appendChild(element.m_element, exception);
    else
        parentNode->insertBefore(element.m_element, siblingNode, exception);
}
开发者ID:dzip,项目名称:webkit,代码行数:31,代码来源:qwebelement.cpp

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

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

示例12: disableSelection

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

示例13: move

void HtmlExtractor::move(QWebElement &element, const QString &file, bool outer)
{
    if(!element.isNull())
    {
        WriteFile(file, outer?element.toOuterXml():element.toInnerXml());
        element.removeFromDocument();
    }
}
开发者ID:BitProfile,项目名称:Xeth,代码行数:8,代码来源:HtmlExtractor.cpp

示例14: setDOMNodes

//#####################################################################
// Function setDOMNodes
//#####################################################################
void Page::setDOMNodes(const QWebElement& domNode) {
    QWebElement domChild = domNode.firstChild();
    while (!domChild.isNull()) {
        setDOMNodes(domChild);
        domChild = domChild.nextSibling();
    }
    mDOMNodes.append(domNode);
}
开发者ID:stereos,项目名称:Webocado,代码行数:11,代码来源:Page.cpp

示例15: appendInside

/*!
    Appends the given \a element as the element's last child.

    If \a element is the child of another element, it is re-parented to this
    element. If \a element is a child of this element, then its position in
    the list of children is changed.

    Calling this function on a null element does nothing.

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

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


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