本文整理汇总了C++中QUrlQuery::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrlQuery::toString方法的具体用法?C++ QUrlQuery::toString怎么用?C++ QUrlQuery::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUrlQuery
的用法示例。
在下文中一共展示了QUrlQuery::toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pushSales
void DeviceAccess::pushSales()
{
QByteArray data;
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(replypushsalescomplete(QNetworkReply *)));
for(int i = 0; i < sales.size(); i++)
{
string s = sales.at(i).value("item").toStdString();
s.erase(
remove( s.begin(), s.end(), '\"' ),
s.end()
);
QNetworkRequest request;
request.setUrl(QUrl("http://vergeapp.com/api/v2/addsales.json"));
QUrlQuery params;
params.addQueryItem("firm", firm);
params.addQueryItem("outlet", outlet);
params.addQueryItem("product_name", QString::fromStdString(s));
params.addQueryItem("price", sales.at(i).value("price"));
params.addQueryItem("quantity", sales.at(i).value("qty"));
params.addQueryItem("reorder", "1");
params.addQueryItem("cost", "2");
qDebug() << params.toString();
manager->post(request, data.append(params.toString()));
}
}
示例2: trackUsage
void UsageTrackerPlugin::trackUsage()
{
QMap<QString, QString> parameters;
collectUsageParameters(parameters);
QUrlQuery query;
QMapIterator<QString, QString> iter(parameters);
while (iter.hasNext()) {
iter.next();
query.addQueryItem(iter.key(), iter.value());
}
// Add checksum
QString hash = getQueryHash(query.toString());
if (shouldSend(hash)) {
query.addQueryItem("hash", hash);
QUrl url("https://www.ratemode.ninja/opver?" + query.toString(QUrl::FullyEncoded));
QNetworkAccessManager *networkAccessManager = new QNetworkAccessManager();
// This will delete the network access manager instance when we're done
connect(networkAccessManager, SIGNAL(finished(QNetworkReply *)), this, SLOT(onFinished(QNetworkReply *)));
connect(networkAccessManager, SIGNAL(finished(QNetworkReply *)), networkAccessManager, SLOT(deleteLater()));
qDebug() << "Sending usage tracking as:" << url.toEncoded(QUrl::FullyEncoded);
networkAccessManager->get(QNetworkRequest(QUrl(url.toEncoded(QUrl::FullyEncoded))));
}
}
示例3: processSales
void DeviceAccess::processSales()
{
//QVector<QHash<QString, QString> >group;
if(transactiongroup.isEmpty())
return;
QByteArray data;
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
for (int i = 0; i < transactiongroup.size(); i++)
{
currentTransactiongroupindex = i;
QVector<QHash<QString, QString> >group = transactiongroup.at(i);
QJsonArray jsonarray;
QString total;
QString receiptno;
QString time;
for (int j = 0; j < group.size(); j++)
{
QJsonObject jsonobject;
total = group.at(j).value("total");
receiptno = group.at(j).value("receiptno");
time = group.at(j).value("time");
jsonobject["item_id"] = QJsonValue(group.at(j).value("id"));
jsonobject["price"] = QJsonValue(group.at(j).value("price"));
jsonobject["quantity"] = QJsonValue(group.at(j).value("qty"));
jsonarray.append(QJsonValue(jsonobject));
}
qDebug() << "Json Array:" << jsonarray;
QNetworkRequest request;
QJsonDocument jdoc = QJsonDocument(jsonarray);
request.setUrl(QUrl("http://vergeapp.com/api/v2/addsales.json"));
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
QUrlQuery params;
params.addQueryItem("appid", appid);
params.addQueryItem("locid", locid);
params.addQueryItem("consumerkey", consumerkey);
params.addQueryItem("paid", total);
params.addQueryItem("payment_type", "cash");
params.addQueryItem("receipt", receiptno);
params.addQueryItem("trans_date", time);
params.addQueryItem("products", jdoc.toJson());
qDebug() << "json::" << jdoc.toJson();
qDebug() << "url---->" << params.toString();
QEventLoop loop;
QNetworkReply *reply = manager->post(request, data.append(params.toString()));
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
replypushsalescomplete(reply);
}
}
示例4: isCaptcha
bool BSClient::isCaptcha(const QByteArray &byteArray)
{
if(byteArray.contains("<head>"))
{
CaptchaDialog dialog(QUrl("http://bs.to/captcha007.gif"));
if(dialog.exec() == QDialog::Accepted)
{
QNetworkRequest request(QUrl("http://bs.to/check-captcha.cgi"));
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
QUrlQuery postData;
postData.addQueryItem("sec", dialog.getText());
QNetworkReply *reply = m_manager->post(request, postData.toString(QUrl::FullyEncoded).toUtf8());
QEventLoop loop;
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
return true;
}
else
qApp->quit();
}
return false;
}
示例5: login
void GagBookManager::login(const QString &username, const QString &password)
{
Q_ASSERT(m_netManager);
if (m_loginReply != 0) {
m_loginReply->disconnect();
m_loginReply->deleteLater();
m_loginReply = 0;
}
if (m_isBusy != true) {
m_isBusy = true;
emit busyChanged();
}
QByteArray postData;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QUrlQuery postDataQuery;
postDataQuery.addQueryItem("username", username);
postDataQuery.addQueryItem("password", password);
postData = postDataQuery.toString(QUrl::FullyEncoded).toUtf8();
#else
QUrl postDataQuery;
postDataQuery.addQueryItem("username", username);
postDataQuery.addQueryItem("password", password);
postData = postDataQuery.encodedQuery();
#endif
m_loginReply = m_netManager->createPostRequest(QUrl("https://9gag.com/login"), postData);
connect(m_loginReply, SIGNAL(finished()), SLOT(onLoginFinished()));
}
示例6: canHist
bool Load::canHist(const Record *record)
{
QUrlQuery query;
query.addQueryItem("source", record->source);
query.addQueryItem("date", "0");
return getProc("hist?" + query.toString());
}
示例7: on_btn_yes_clicked
void CWizCrashReportDialog::on_btn_yes_clicked()
{
accept();
QString text = m_reports;
QtConcurrent::run([text](){
QString reportText = text;
const int maxSize = 1024 * 128 - 100;
if (reportText.size() > maxSize)
{
reportText.truncate(maxSize);
reportText.append("\n Wow! too may words, truncated!");
}
//
QString url = WizService::WizApiEntry::crashReportUrl();
QNetworkRequest request(url);
request.setHeader(QNetworkRequest::ContentTypeHeader,
"application/x-www-form-urlencoded");
QUrlQuery postData;
postData.addQueryItem("platform", "mac");
postData.addQueryItem("token", "");
postData.addQueryItem("subject", "Version: " + QString(WIZ_CLIENT_VERSION) + " UUID : " + WizGenGUIDLowerCaseLetterOnly());
postData.addQueryItem("error", reportText);
QNetworkAccessManager net;
QNetworkReply* reply = net.post(request, postData.toString(QUrl::FullyEncoded).toUtf8());
CWizAutoTimeOutEventLoop loop(reply);
loop.exec();
if (loop.error() != QNetworkReply::NoError)
{
qDebug() << "[Crash report]Upload failed!";
return;
}
rapidjson::Document d;
d.Parse<0>(loop.result().toUtf8().constData());
if (!d.HasMember("return_code"))
{
qDebug() << "[Crash report]Can not get return code ";
return;
}
int returnCode = d.FindMember("return_code")->value.GetInt();
if (returnCode != 200)
{
qDebug() << "[Crash report]Return code was not 200, error : " << returnCode << loop.result();
return;
}
else
{
qDebug() << "[Crash report]Upload OK";
}
});
}
示例8: loadHistory
void Load::loadHistory(const Record *record, QDate date)
{
QUrlQuery query;
query.addQueryItem("source", record->source);
query.addQueryItem("date", QString::number(date.isValid() ? QDateTime(date).toTime_t() : 0));
const Task &task = codeToTask("hist?" + query.toString());
enqueue(task);
}
示例9: requestCreateContact
void QPushbulletHandler::requestCreateContact(QString name, QString email)
{
QUrlQuery query;
query.addQueryItem("name", name);
query.addQueryItem("email", email);
m_CurrentOperation = CURRENT_OPERATION::CREATE_CONTACT;
postRequest(m_URLContacts, query.toString(QUrl::FullyEncoded).toUtf8());
}
示例10: 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);
}
示例11: 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);
}
});
}
示例12: requestDeviceUpdate
void QPushbulletHandler::requestDeviceUpdate(QString deviceID, QString newNickname)
{
QString url = m_URLDevices.toString();
url.append("/");
url.append(deviceID);
QUrl modifiedURL(url);
QUrlQuery query;
query.addQueryItem("nickname", newNickname);
m_CurrentOperation = CURRENT_OPERATION::UPDATE_DEVICE;
postRequest(modifiedURL, query.toString(QUrl::FullyEncoded).toUtf8());
}
示例13: requestPushUpdate
void QPushbulletHandler::requestPushUpdate(QString pushID, bool dismissed)
{
QUrlQuery query;
query.addQueryItem("dismissed", dismissed ? "true" : "false");
QString url = m_URLPushes.toString();
url.append("/");
url.append(pushID);
QUrl modifiedURL(url);
m_CurrentOperation = CURRENT_OPERATION::PUSH_UPDATE;
postRequest(modifiedURL, query.toString(QUrl::FullyEncoded).toUtf8());
}
示例14: requestContactUpdate
void QPushbulletHandler::requestContactUpdate(QString contactID, QString newName)
{
QString url = m_URLContacts.toString();
url.append("/");
url.append(contactID);
QUrl modifiedURL(url);
QUrlQuery query;
query.addQueryItem("name", newName);
m_CurrentOperation = CURRENT_OPERATION::UPDATE_CONTACT;
postRequest(modifiedURL, query.toString(QUrl::FullyEncoded).toUtf8());
}
示例15: requestDeviceDelete
void QPushbulletHandler::requestDeviceDelete(QString deviceID)
{
QString url = m_URLDevices.toString();
url.append("/");
url.append(deviceID);
QUrl modifiedURL(url);
m_CurrentOperation = CURRENT_OPERATION::DELETE_DEVICE;
QUrlQuery query;
query.setQueryDelimiters(' ', '&');
query.addQueryItem("-X", "DELETE");
postRequest(modifiedURL, query.toString(QUrl::FullyEncoded).toUtf8());
}