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


C++ QUrlQuery类代码示例

本文整理汇总了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;
}
开发者ID:cutelyst,项目名称:cutelyst,代码行数:45,代码来源:context.cpp

示例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()));
}
开发者ID:Methtra,项目名称:acquisition,代码行数:29,代码来源:logindialog.cpp

示例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);
}
开发者ID:Spiek,项目名称:telegrambotlib-qt,代码行数:26,代码来源:telegrambot.cpp

示例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();
}
开发者ID:oSvirzh,项目名称:vk-api2,代码行数:18,代码来源:widget.cpp

示例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);
}
开发者ID:Gloorf,项目名称:acquisition,代码行数:18,代码来源:itemsmanagerworker.cpp

示例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);
}
开发者ID:ElanGroup,项目名称:freelance-navigator,代码行数:9,代码来源:apirequest.cpp

示例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_()));
}
开发者ID:zedd4x,项目名称:vpaint,代码行数:18,代码来源:AboutDialog.cpp

示例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;
}
开发者ID:AdrianBZG,项目名称:SyncMe,代码行数:18,代码来源:SM_qdropbox.cpp

示例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);
}
开发者ID:amccarthy,项目名称:qtlocation,代码行数:18,代码来源:appmodel.cpp

示例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();
}
开发者ID:bsxf-47,项目名称:ArxLibertatis,代码行数:18,代码来源:TBG.cpp

示例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);
}
开发者ID:guoyu07,项目名称:Mu,代码行数:19,代码来源:knaccount.cpp

示例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;
}
开发者ID:johnbolia,项目名称:schat,代码行数:25,代码来源:ChatUrls.cpp

示例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);
}
开发者ID:Nokius,项目名称:harbour-hipsterfish,代码行数:19,代码来源:instagramclient.cpp

示例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);
    }
}
开发者ID:Brli,项目名称:Qelly,代码行数:19,代码来源:View.cpp

示例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()));
}
开发者ID:samizzo,项目名称:canon-tweet,代码行数:25,代码来源:oauthtwitter.cpp


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