本文整理汇总了C++中QUrl::setEncodedFragment方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrl::setEncodedFragment方法的具体用法?C++ QUrl::setEncodedFragment怎么用?C++ QUrl::setEncodedFragment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUrl
的用法示例。
在下文中一共展示了QUrl::setEncodedFragment方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse
/* The parse function is invoked after the loadFinished signal is received
* from the webkit code upon successfully parsing a page. From here, the
* entire DOM can be manipulated and traversed really conveniently. The
* code right now just traverses the DOM looking for link tags, and queues
* them if they are valid, but this function is where all of the
* interesting development will take place in the future.
*/
void Parser::parse() {
QUrl currentUrl;
QWebElementCollection linkTags =
page->mainFrame()->findAllElements("a");
foreach(QWebElement current, linkTags) {
currentUrl = QUrl(current.attribute("href"));
/* This discards the fragment. It is useless in this context and
* will complicate our visited hashtable.
*/
currentUrl.setEncodedFragment(QByteArray());
if (currentUrl.isEmpty()) {
continue;
}
/* Prepend the parent URL if we have a relative link in an attempt
* to validate it for retrieval.
*/
if (currentUrl.isRelative() &&
currentUrl.host() == "" && currentUrl.path() != "") {
qDebug() << currentUrl << " is relative path. prepending host";
currentUrl.setHost(url.host());
currentUrl.setScheme(url.scheme());
qDebug() << "with host fix: " << currentUrl;
}
/* Finally, check to make sure it's valid before queueing it */
if (validateUrl(currentUrl)) {
parsedUrls.push_back(currentUrl);
}
}
示例2: proxiedRequest
bool Pillow::HttpHandlerProxy::handleRequest(Pillow::HttpConnection *request)
{
if (_proxiedUrl.isEmpty()) return false;
QUrl targetUrl = _proxiedUrl;
targetUrl.setEncodedPath(request->requestPath());
if (!request->requestQueryString().isEmpty()) targetUrl.setEncodedQuery(request->requestQueryString());
if (!request->requestFragment().isEmpty()) targetUrl.setEncodedFragment(request->requestFragment());
QNetworkRequest proxiedRequest(targetUrl);
foreach (const Pillow::HttpHeader& header, request->requestHeaders())
proxiedRequest.setRawHeader(header.first, header.second);
createPipe(request, createProxiedReply(request, proxiedRequest));
return true;
}
示例3: setEncodedFragment
void QUrlProto::setEncodedFragment(const QByteArray &fragment)
{
QUrl *item = qscriptvalue_cast<QUrl*>(thisObject());
if (item)
item->setEncodedFragment(fragment);
}