本文整理汇总了C++中QUrlQuery::addQueryItem方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrlQuery::addQueryItem方法的具体用法?C++ QUrlQuery::addQueryItem怎么用?C++ QUrlQuery::addQueryItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUrlQuery
的用法示例。
在下文中一共展示了QUrlQuery::addQueryItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: forwardMessage
void TelegramBot::forwardMessage(QVariant targetChatId, QVariant fromChatId, qint32 fromMessageId, TelegramFlags flags, TelegramBotMessage *response)
{
QUrlQuery params;
params.addQueryItem("chat_id", targetChatId.toString());
params.addQueryItem("from_chat_id", fromChatId.toString());
params.addQueryItem("message_id", QString::number(fromMessageId));
if(flags && TelegramFlags::DisableNotfication) params.addQueryItem("disable_notification", "true");
this->callApiTemplate("forwardMessage", params, response);
}
示例2: getUserProfilePhotos
/*
* User Functions
*/
TelegramBotUserProfilePhotos TelegramBot::getUserProfilePhotos(qint32 userId, int offset, int limit)
{
QUrlQuery params;
params.addQueryItem("user_id", QString::number(userId));
if(offset > 0) params.addQueryItem("offset", QString::number(offset));
if(limit > 0) params.addQueryItem("limit", QString::number(limit));
// call api and return constructed data
return TelegramBotUserProfilePhotos(this->callApiJson("getUserProfilePhotos", params).value("result").toObject());
}
示例3: getFindRequest
GoogleFeedHttpRequest* QtGoogleFeedApi::getFindRequest(QString query)
{
QUrlQuery urlQuery;
urlQuery.addQueryItem("v", versionString());
urlQuery.addQueryItem("q", query);
QUrl url(QtGoogleFeedApi::BaseUrl + "/find");
url.setQuery(urlQuery);
return new GoogleFeedHttpRequest(url);
}
示例4: text
QString BoardGameGeekImporter::text(const QStringList& idList_) const {
// myDebug() << idList_;
QUrl u(QString::fromLatin1(BGG_THING_URL));
QUrlQuery q;
q.addQueryItem(QLatin1String("id"), idList_.join(QLatin1String(",")));
q.addQueryItem(QLatin1String("type"), QLatin1String("boardgame,boardgameexpansion"));
u.setQuery(q);
// myDebug() << u;
return FileHandler::readTextFile(u, true, true);
}
示例5: user_update
QJsonObject festrip_api::user_update(QString password,
QString nickname,
QString twitterId,
QString name,
QString lastname,
QString gender,
QString countryId,
QString cityId,
QString avatar)
{
QUrlQuery query = QUrlQuery(QUrl(QString(FESTRIP_URL).append("/api/user/")));
// Fill in query
query.addQueryItem("query", "update");
query.addQueryItem("token", token.toString());
query.addQueryItem("password", password);
query.addQueryItem("nickname", nickname);
query.addQueryItem("twitterId", twitterId);
query.addQueryItem("name", name);
query.addQueryItem("lastname", lastname);
query.addQueryItem("gender", gender);
query.addQueryItem("countryId", countryId);
query.addQueryItem("cityId", cityId);
query.addQueryItem("avatar", avatar);
// Send query to server
QJsonObject response = send_query(POST, query);
// Return JSON
return(response);
}
示例6: findStationsByCoordinates
void ParserResRobot::findStationsByCoordinates(qreal longitude, qreal latitude)
{
if (currentRequestState != FahrplanNS::noneRequest)
return;
currentRequestState = FahrplanNS::stationsByCoordinatesRequest;
QUrl url(baseURL + QLatin1String("/location.nearbystops"));
#if defined(BUILD_FOR_QT5)
QUrlQuery query;
#else
QUrl query;
#endif
query.addQueryItem("key", journeyAPIKey);
query.addQueryItem("originCoordLat", QString::number(latitude));
query.addQueryItem("originCoordLong", QString::number(longitude));
query.addQueryItem("r", "1000"); // Radius in meters
query.addQueryItem("maxNo", "30"); // Max number of results
if (QLocale().language() == QLocale::Swedish)
query.addQueryItem("lang", "sv");
else if (QLocale().language() == QLocale::German)
query.addQueryItem("lang", "de");
else
query.addQueryItem("lang", "en");
query.addQueryItem("format", "json");
#if defined(BUILD_FOR_QT5)
url.setQuery(query);
#else
url.setQueryItems(query.queryItems());
#endif
sendHttpRequest(url);
}
示例7: connectToAccount
QNetworkReply* Connection::connectToAccount(const QString &email,
const QString &password,
PMS::SimpleResultHandler handler)
{
QUrlQuery query;
query.addQueryItem("api_subscription[email]", email);
query.addQueryItem("api_subscription[password]", password);
query.addQueryItem("api_subscription[client_name]", qApp->applicationName());
query.addQueryItem("api_subscription[client_vendor]", qApp->organizationName());
QNetworkRequest request(apiUrl_);
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/x-www-form-urlencoded");
auto reply = client_->post(request, query.toString().toUtf8());
QPointer<QObject> self = this;
QObject::connect(reply, &QNetworkReply::finished, [self, this, reply, handler]()
{
if (!self)
return;
try
{
checkReply(reply);
auto str = reply->readAll().trimmed();
QRegExp apiKeyRx("^API key: (.+)$");
if (apiKeyRx.exactMatch(str))
{
setApiKey(apiKeyRx.cap(1));
handler(Error());
return;
}
QRegExp errorRx("^Error Code: (\\d+)$");
if (errorRx.exactMatch(str))
{
int code = errorRx.cap(1).toInt();
QString error;
switch (code)
{
case 1: error = tr("Client details not set"); break;
case 2: error = tr("Unknown user"); break;
case 3: error = tr("Invalid password"); break;
case 4: error = tr("Not allowed for given User and their System Role"); break;
default: error = tr("Unknown error"); break;
}
throw Error(Error::Authorization, error);
}
throw Error(Error::Authorization, tr("Unknown error"));
}
catch (const Error& err)
{
handler(err);
}
});
}
示例8: multiAddRemove
void tst_QUrlQuery::multiAddRemove()
{
QUrlQuery query;
{
// one item, two values
query.addQueryItem("a", "b");
query.addQueryItem("a", "c");
QVERIFY(!query.isEmpty());
QVERIFY(query.hasQueryItem("a"));
// returns the first one
QVERIFY(query.queryItemValue("a") == "b");
// order is the order we set them in
QVERIFY(query.allQueryItemValues("a") == QStringList() << "b" << "c");
}
{
// add another item, two values
query.addQueryItem("A", "B");
query.addQueryItem("A", "C");
QVERIFY(query.hasQueryItem("A"));
QVERIFY(query.hasQueryItem("a"));
QVERIFY(query.queryItemValue("a") == "b");
QVERIFY(query.allQueryItemValues("a") == QStringList() << "b" << "c");
QVERIFY(query.queryItemValue("A") == "B");
QVERIFY(query.allQueryItemValues("A") == QStringList() << "B" << "C");
}
{
// remove one of the original items
query.removeQueryItem("a");
QVERIFY(query.hasQueryItem("a"));
// it must have removed the first one
QVERIFY(query.queryItemValue("a") == "c");
}
{
// remove the items we added later
query.removeAllQueryItems("A");
QVERIFY(!query.isEmpty());
QVERIFY(!query.hasQueryItem("A"));
}
{
// add one element to the current, then remove them
query.addQueryItem("a", "d");
query.removeAllQueryItems("a");
QVERIFY(!query.hasQueryItem("a"));
QVERIFY(query.isEmpty());
}
}
示例9: method
void VKApi::method(const QString &method,
const QMap<QString, QString> params,
std::function< void(const QJsonDocument*, QNetworkReply::NetworkError) > callback
) {
QUrl url( kApiBaseUrl + method );
QUrlQuery q;
if (!params.empty()) {
for (const auto& key : params) {
q.addQueryItem( key, params.value(key) );
}
}
if (isLoggedIn())
q.addQueryItem("access_token", accessToken);
url.setQuery(q);
QNetworkRequest req;
req.setUrl(url);
qDebug() << "Sending request to: " << req.url().toString() << "\n";
auto reply = net.get(req);
connect(reply, &QNetworkReply::finished, [reply, callback]() {
QJsonDocument* json = 0;
QJsonDocument jsonDoc;
QNetworkReply::NetworkError error = reply->error();
qDebug() << "Finished reply: " << reply << "\n";
if (reply->error() != QNetworkReply::NetworkError::NoError) {
qDebug() << "Network error: " << reply->errorString() << "\n";
} else {
QJsonParseError parseErr;
auto data = reply->readAll();
jsonDoc = QJsonDocument::fromJson(data , &parseErr );
qDebug() << "got response <" << reply->url() << ">\n" << data << "\n\n\n";
if (parseErr.error != QJsonParseError::NoError) {
qDebug() << "failed to parse json: " << parseErr.errorString() << "\n";
error = QNetworkReply::NetworkError::UnknownContentError;
} else if (!jsonDoc.object().contains("response")) {
qDebug() << "bad json.\n";
error = QNetworkReply::NetworkError::UnknownContentError;
} else {
jsonDoc = QJsonDocument( jsonDoc.object().value( "response" ).toArray().at(0).toObject() );
json = &jsonDoc;
}
}
if (callback)
callback(json, error);
reply->deleteLater();
});
}
示例10: write_on_disk
void IpfsGet::write_on_disk(const IpfsHash &hash, const QString &path)
{
QUrl url = Ipfs::instance().api_url(API_COMMAND);
QUrlQuery query;
query.addQueryItem("arg", hash.ToString());
query.addQueryItem("o", path);
url.setQuery(query);
Ipfs::instance().query(url);
}
示例11: answerCallbackQuery
/*
* Callback Query Functions
*/
void TelegramBot::answerCallbackQuery(QString callbackQueryId, QString text, bool showAlert, int cacheTime, QString url, bool *response)
{
QUrlQuery params;
params.addQueryItem("callback_query_id", callbackQueryId);
if(!text.isNull()) params.addQueryItem("text", text);
if(showAlert) params.addQueryItem("show_alert", "true");
if(!url.isNull()) params.addQueryItem("url", url);
if(cacheTime > 0) params.addQueryItem("cache_time", QString::number(cacheTime));
this->callApiTemplate("answerCallbackQuery", params, response);
}
示例12: MakeTabRequest
QNetworkRequest ItemsManagerWorker::MakeTabRequest(int tab_index, bool tabs) {
QUrlQuery query;
query.addQueryItem("league", league_.c_str());
query.addQueryItem("tabs", tabs ? "1" : "0");
query.addQueryItem("tabIndex", QString::number(tab_index));
query.addQueryItem("accountName", account_name_.c_str());
QUrl url(kStashItemsUrl);
url.setQuery(query);
return QNetworkRequest(url);
}
示例13: shareViaTwitter
void MediaView::shareViaTwitter() {
Video *video = playlistModel->activeVideo();
if (!video) return;
QUrl url("https://twitter.com/intent/tweet");
QUrlQuery q;
q.addQueryItem("via", "minitubeapp");
q.addQueryItem("text", video->getTitle());
q.addQueryItem("url", video->getWebpage());
url.setQuery(q);
QDesktopServices::openUrl(url);
}
示例14: getToken
void MToken::getToken() {
QUrl current("https://www.deviantart.com/oauth2/token");
QUrlQuery par;
par.addQueryItem("grant_type", "client_credentials");
// Add your id and secret to run
par.addQueryItem("client_id", "4146");
par.addQueryItem("client_secret", "74324cd51181766352ee8246178cda69");
current.setQuery(par);
token = QJsonDocument::fromJson(GETt(current)).object().value("access_token").toString();
qDebug() << "Token: " << token;
}
示例15: createGetFeatureUrl
void WfsCapabilitiesParser::createGetFeatureUrl(const QString& featureName, QUrl& rawUrl, QUrl& normalizedUrl) const
{
QUrlQuery query;
query.addQueryItem("service", "WFS");
query.addQueryItem("version", "1.1.0");
query.addQueryItem("request", "GetFeature");
query.addQueryItem("typeName", featureName);
rawUrl = _wfsResource.url(); // copy
rawUrl.setQuery(query);
normalizedUrl = _wfsResource.url().toString(QUrl::RemoveQuery) + "/" + featureName;
}