本文整理汇总了C++中QUrl::setEncodedQueryItems方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrl::setEncodedQueryItems方法的具体用法?C++ QUrl::setEncodedQueryItems怎么用?C++ QUrl::setEncodedQueryItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUrl
的用法示例。
在下文中一共展示了QUrl::setEncodedQueryItems方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loginUrlRequestCompleted
void NetFlixAuthProxy::loginUrlRequestCompleted(int retCode, QString body)
{
qDebug() << "temp token completed!!";
qDebug() << retCode;
qDebug() << body;
QUrl parser;
parser.setEncodedQuery(body.toUtf8());
QString url = parser.queryItemValue(STR(NETFLIX_LOGIN_URL_PARAM));
parser.removeQueryItem(STR(NETFLIX_LOGIN_URL_PARAM));
QString token = parser.queryItemValue(STR(OAUTH_TOKEN));
QString token_secret = parser.queryItemValue(STR(OAUTH_TOKEN_SECRET));
parser.removeQueryItem(STR(OAUTH_TOKEN_SECRET));
settings->setOAuthToken(token);
settings->setOAuthTokenSecret(token_secret);
QUrl loginUrl = QUrl(url);
loginUrl.setEncodedQueryItems(parser.encodedQueryItems());
qDebug() << loginUrl.toEncoded();
emit getTokenUrlSucceeded(loginUrl);
}
示例2: addEngineFromForm
void SearchEnginesManager::addEngineFromForm(const QWebElement &element, WebView* view)
{
QWebElement formElement = element.parent();
while (!formElement.isNull()) {
if (formElement.tagName().toLower() == QLatin1String("form")) {
break;
}
formElement = formElement.parent();
}
if (formElement.isNull()) {
return;
}
const QString method = formElement.hasAttribute("method") ? formElement.attribute("method").toUpper() : "GET";
bool isPost = method == QLatin1String("POST");
QUrl actionUrl = QUrl::fromEncoded(formElement.attribute("action").toUtf8());
if (actionUrl.isRelative()) {
actionUrl = view->url().resolved(actionUrl);
}
QUrl parameterUrl = actionUrl;
if (isPost) {
parameterUrl = QUrl("http://foo.bar");
}
#if QT_VERSION >= 0x050000
QUrlQuery query(parameterUrl);
query.addQueryItem(element.attribute("name"), "%s");
QWebElementCollection allInputs = formElement.findAll("input");
foreach (QWebElement e, allInputs) {
if (element == e || !e.hasAttribute("name")) {
continue;
}
query.addQueryItem(e.attribute("name"), e.evaluateJavaScript("this.value").toString());
}
parameterUrl.setQuery(query);
#else
QList<QPair<QByteArray, QByteArray> > queryItems;
QPair<QByteArray, QByteArray> item;
item.first = element.attribute("name").toUtf8();
item.second = "%s";
queryItems.append(item);
QWebElementCollection allInputs = formElement.findAll("input");
foreach (QWebElement e, allInputs) {
if (element == e || !e.hasAttribute("name")) {
continue;
}
QPair<QByteArray, QByteArray> item;
item.first = QUrl::toPercentEncoding(e.attribute("name").toUtf8());
item.second = QUrl::toPercentEncoding(e.evaluateJavaScript("this.value").toByteArray());
queryItems.append(item);
}
parameterUrl.setEncodedQueryItems(parameterUrl.encodedQueryItems() + queryItems);
#endif
if (!isPost) {
actionUrl = parameterUrl;
}
SearchEngine engine;
engine.name = view->title();
engine.icon = view->icon();
engine.url = actionUrl.toEncoded();
if (isPost) {
QByteArray data = parameterUrl.toEncoded(QUrl::RemoveScheme);
engine.postData = data.contains('?') ? data.mid(data.lastIndexOf('?') + 1) : QByteArray();
}
EditSearchEngine dialog(SearchEnginesDialog::tr("Add Search Engine"), view);
dialog.setName(engine.name);
dialog.setIcon(engine.icon);
dialog.setUrl(engine.url);
dialog.setPostData(engine.postData);
if (dialog.exec() != QDialog::Accepted) {
return;
}
engine.name = dialog.name();
engine.icon = dialog.icon();
engine.url = dialog.url();
engine.shortcut = dialog.shortcut();
engine.postData = dialog.postData().toUtf8();
if (engine.name.isEmpty() || engine.url.isEmpty()) {
return;
//.........这里部分代码省略.........
示例3: setEncodedQueryItems
void QUrlProto::setEncodedQueryItems(const QList<QPair<QByteArray, QByteArray> > &query)
{
QUrl *item = qscriptvalue_cast<QUrl*>(thisObject());
if (item)
item->setEncodedQueryItems(query);
}