本文整理汇总了C++中QUrlQuery类的典型用法代码示例。如果您正苦于以下问题:C++ QUrlQuery类的具体用法?C++ QUrlQuery怎么用?C++ QUrlQuery使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QUrlQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Q_D
QUrl Context::uriFor(const QString &path, const QStringList &args, const ParamsMultiMap &queryValues) const
{
Q_D(const Context);
QUrl uri = d->request->uri();
QString _path;
if (path.isEmpty()) {
// ns must NOT return a leading slash
const QString controllerNS = d->action->controller()->ns();
if (!controllerNS.isEmpty()) {
_path.prepend(controllerNS);
}
} else {
_path = path;
}
if (!args.isEmpty()) {
if (_path == QLatin1String("/")) {
_path += args.join(QLatin1Char('/'));
} else {
_path = _path + QLatin1Char('/') + args.join(QLatin1Char('/'));
}
}
if (!_path.startsWith(QLatin1Char('/'))) {
_path.prepend(QLatin1Char('/'));
}
uri.setPath(_path, QUrl::DecodedMode);
QUrlQuery query;
if (!queryValues.isEmpty()) {
// Avoid a trailing '?'
if (queryValues.size()) {
auto it = queryValues.constEnd();
while (it != queryValues.constBegin()) {
--it;
query.addQueryItem(it.key(), it.value());
}
}
}
uri.setQuery(query);
return uri;
}
示例2: DisplayError
void LoginDialog::OnLoginPageFinished() {
QNetworkReply *reply = qobject_cast<QNetworkReply *>(QObject::sender());
if (reply->error()) {
DisplayError("Network error: " + reply->errorString() + "\nTry using another login method.");
return;
}
QByteArray bytes = reply->readAll();
std::string page(bytes.constData(), bytes.size());
std::string hash = Util::GetCsrfToken(page, "hash");
if (hash.empty()) {
DisplayError("Failed to log in (can't extract form hash from page)");
return;
}
QUrlQuery query;
query.addQueryItem("login_email", EncodeSpecialCharacters(ui->emailLineEdit->text()));
query.addQueryItem("login_password", EncodeSpecialCharacters(ui->passwordLineEdit->text()));
query.addQueryItem("hash", QString(hash.c_str()));
query.addQueryItem("login", "Login");
query.addQueryItem("remember_me", "1");
QUrl url(POE_LOGIN_URL);
QByteArray data(query.query().toUtf8());
QNetworkRequest request(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
QNetworkReply *logged_in = login_manager_->post(request, data);
connect(logged_in, SIGNAL(finished()), this, SLOT(OnLoggedIn()));
}
示例3: editMessageText
void TelegramBot::editMessageText(QVariant chatId, QVariant messageId, QString text, TelegramFlags flags, TelegramKeyboardRequest keyboard, bool *response)
{
// if we have a null messageId, and user don't request a response, call send Message
if(!response && messageId.isNull()) {
return this->sendMessage(chatId, text, 0, flags, keyboard);
}
// determine message id type
bool isInlineMessageId = messageId.type() == QVariant::String;
QUrlQuery params;
if(!isInlineMessageId && !chatId.isNull()) params.addQueryItem("chat_id", chatId.toString());
params.addQueryItem(isInlineMessageId ? "inline_message_id" : "message_id", messageId.toString());
params.addQueryItem("text", text);
if(flags && TelegramFlags::Markdown) params.addQueryItem("parse_mode", "Markdown");
else if(flags && TelegramFlags::Html) params.addQueryItem("parse_mode", "HTML");
if(flags && TelegramFlags::DisableWebPagePreview) params.addQueryItem("disable_web_page_preview", "true");
// only build inline keyboard
if(!(flags && TelegramFlags::ReplyKeyboardMarkup) && !(flags && TelegramFlags::ForceReply) && !(flags && TelegramFlags::ReplyKeyboardRemove)) {
this->hanldeReplyMarkup(params, flags, keyboard);
}
// call api
this->callApiTemplate("editMessageText", params, response);
}
示例4: current
void Widget::wall_post()
{
QString text = ui->WallTextPost->text();
QUrl current("https://api.vk.com/method/wall.post");
QUrlQuery Param;
Param.addQueryItem("access_token",Setting::access_token);
Param.addQueryItem("message",text);
Param.addQueryItem("v","5.40");
current.setQuery(Param);
QByteArray answer = GET(current);
if(answer.isEmpty())
{
qDebug() << "Нe zapostilo";
exit(-1);
}
ui->WallTextPost->clear();
}
示例5: MakeTabRequest
QNetworkRequest ItemsManagerWorker::MakeTabRequest(int tab_index, const ItemLocation &location, 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);
TabCache::Flags flags;
if (tabs) flags |= TabCache::Refresh;
if (!location.IsValid() || bo_manager_.GetRefreshChecked(location))
flags |= TabCache::Refresh;
return Request(url, location, flags);
}
示例6: post
void ApiRequest::post(const QUrlQuery & data) const
{
m_request->setUrl(url());
m_request->setHeader(QNetworkRequest::ContentTypeHeader,
QStringLiteral("application/x-www-form-urlencoded"));
QNetworkReply * reply =
m_networkManager->post(*m_request, data.toString(QUrl::FullyEncoded).toUtf8());
connect(reply, &QNetworkReply::finished, this, &ApiRequest::processReply);
}
示例7: processSubscribe_
void AboutDialog::processSubscribe_()
{
// Set query
QUrlQuery urlQuery;
urlQuery.addQueryItem("emailaddress", subscribeLineEdit_->text());
QUrl url = QUrl("http://www.vpaint.org/subscribeext.php");
QNetworkRequest networkRequest(url);
networkRequest.setHeader(QNetworkRequest::ContentTypeHeader,
"application/x-www-form-urlencoded; charset=utf-8");
// Send query
QString urlQueryString = urlQuery.toString(QUrl::FullyEncoded);
urlQueryString.replace('+', "%2B");
reply_ = networkManager_->post(networkRequest, urlQueryString.toUtf8());
// Connection to process reply
connect(reply_, SIGNAL(finished()), this, SLOT(processFinished_()));
}
示例8: qDebug
int SM_QDropbox::authorize(QString email, QString pwd)
{
QUrl dropbox_authorize;
dropbox_authorize.setPath(QString("/%1/oauth/authorize")
.arg(_version.left(1)));
#ifdef SM_QTDROPBOX_DEBUG
qDebug() << "oauthToken = " << oauthToken << endl;
#endif
QUrlQuery query;
query.addQueryItem("oauth_token", oauthToken);
dropbox_authorize.setQuery(query);
int reqnr = sendRequest(dropbox_authorize, "GET", 0, "www.dropbox.com");
requestMap[reqnr].type = SM_DROPBOX_REQ_AULOGIN;
mail = email;
password = pwd;
return reqnr;
}
示例9: url
void AppModel::refreshWeather()
{
QUrl url("http://www.google.com/ig/api");
QUrlQuery query;
query.addQueryItem("hl", "en");
query.addQueryItem("weather", d->city);
url.setQuery(query);
QNetworkReply *rep = d->nam->get(QNetworkRequest(url));
// connect up the signal right away
d->weatherReplyMapper->setMapping(rep, rep);
connect(rep, SIGNAL(finished()),
d->weatherReplyMapper, SLOT(map()));
// it might have finished though while we were connecting it
// if so, pass it straight on
if (rep->isFinished())
this->handleWeatherNetworkData(rep);
}
示例10: addComment
bool Server::addComment(int issue_id, const QString & comment) {
QUrlQuery params;
params.addQueryItem("comment_visibility", "1");
params.addQueryItem("comment_body", comment);
params.addQueryItem("comment_save_changes", "1");
QString format = "/comment/add/for/module/core/item/type/1/id/%1";
QString url = format.arg(QString::number(issue_id));
http::POSTRequest request(toUTF8(m_serverPrefix + url));
request.setData(qUrlQueryToPostData(params));
request.setFollowRedirects(false);
boost::scoped_ptr<http::Response> response(post(request));
return response->ok();
}
示例11: loginWith
inline int KNAccount::loginWith(const QString &username,
const QString &password,
QByteArray &responseCache)
{
//Generate the login request.
QNetworkRequest loginRequest=generateKreogistRequest("login");
//Construct the json struct.
//Try to login with encrypted password first.
QUrlQuery loginQuery;
//Insert user name.
loginQuery.addQueryItem("username", username);
loginQuery.addQueryItem("password", password);
//Insert login query to login url.
QUrl loginUrl=loginRequest.url();
loginUrl.setQuery(loginQuery);
loginRequest.setUrl(loginUrl);
//Get the login result.
return get(loginRequest, responseCache, false);
}
示例12: out
/*!
* Преобразует канал в URL адрес.
*
* \param channel Указатель на канал.
* \param action Действие над каналом.
*/
QUrl ChatUrls::toUrl(ClientChannel channel, const QString &action)
{
QUrl out(LS("chat://channel"));
out.setPath(SimpleID::encode(channel->id()) + (action.isEmpty() ? QString() : "/" + action));
QList<QPair<QString, QString> > queries;
queries.append(QPair<QString, QString>(LS("name"), ChatId::toBase32(channel->name().toUtf8())));
queries.append(QPair<QString, QString>(LS("gender"), QString::number(channel->gender().raw())));
# if QT_VERSION >= 0x050000
QUrlQuery query;
query.setQueryItems(queries);
out.setQuery(query);
# else
out.setQueryItems(queries);
# endif
return out;
}
示例13: createCleanedUuid
void InstagramClient::discover(QString maxID, QJSValue callback)
{
static QString sessionID;
if (maxID.isEmpty() || sessionID.isEmpty())
sessionID = createCleanedUuid();
QUrlQuery q;
q.addQueryItem("is_prefetch", "false");
q.addQueryItem("session_id", sessionID);
if (!maxID.isEmpty())
q.addQueryItem("max_id", maxID);
QUrl url("https://i.instagram.com/api/v1/discover/explore/");
url.setQuery(q);
executeGetRequest(url, callback);
}
示例14: url
void View::google()
{
QString queryString;
QAction *action = qobject_cast<QAction *>(sender());
if (action)
queryString = action->data().toString();
if (!queryString.isEmpty())
{
QUrl url("http://www.google.com/search");
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
url.addEncodedQueryItem("q", QUrl::toPercentEncoding(queryString));
#else
QUrlQuery query;
query.addQueryItem("q", QUrl::toPercentEncoding(queryString));
url.setQuery(query);
#endif
QDesktopServices::openUrl(url);
}
}
示例15: Q_ASSERT
/**
* Gets oauth tokens using XAuth method (starts authorization process)
* @param username username
* @param password password
* @remarks Async, emits authorizeXAuthFinished or authorizeXAuthError when there is error
*/
void OAuthTwitter::authorizeXAuth(const QString &username, const QString &password)
{
Q_ASSERT(m_netManager != 0);
QUrl url(TWITTER_ACCESS_TOKEN_XAUTH_URL);
QUrlQuery query;
query.addQueryItem("x_auth_username", username.toUtf8().toPercentEncoding());
query.addQueryItem("x_auth_password", password.toUtf8().toPercentEncoding());
query.addQueryItem("x_auth_mode", "client_auth");
url.setQuery(query);
QByteArray oauthHeader = generateAuthorizationHeader(url, OAuth::POST);
QNetworkRequest req(url);
req.setRawHeader(AUTH_HEADER, oauthHeader);
QNetworkReply *reply = m_netManager->post(req, QByteArray());
connect(reply, SIGNAL(finished()), this, SLOT(finishedAuthorization()));
}