本文整理汇总了C++中QUrlQuery::setQueryItems方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrlQuery::setQueryItems方法的具体用法?C++ QUrlQuery::setQueryItems怎么用?C++ QUrlQuery::setQueryItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUrlQuery
的用法示例。
在下文中一共展示了QUrlQuery::setQueryItems方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: old_queryItems
void tst_QUrlQuery::old_queryItems()
{
// test imported from old tst_qurl.cpp
QUrlQuery url;
QList<QPair<QString, QString> > newItems;
newItems += qMakePair(QString("1"), QString("a"));
newItems += qMakePair(QString("2"), QString("b"));
newItems += qMakePair(QString("3"), QString("c"));
newItems += qMakePair(QString("4"), QString("a b"));
newItems += qMakePair(QString("5"), QString("&"));
newItems += qMakePair(QString("foo bar"), QString("hello world"));
newItems += qMakePair(QString("foo+bar"), QString("hello+world"));
newItems += qMakePair(QString("tex"), QString("a + b = c"));
url.setQueryItems(newItems);
QVERIFY(!url.isEmpty());
QList<QPair<QString, QString> > setItems = url.queryItems();
QVERIFY(newItems == setItems);
url.addQueryItem("1", "z");
#if 0
// undefined behaviour in the new QUrlQuery
QVERIFY(url.hasQueryItem("1"));
QCOMPARE(url.queryItemValue("1").toLatin1().constData(), "a");
url.addQueryItem("1", "zz");
QStringList expected;
expected += "a";
expected += "z";
expected += "zz";
QCOMPARE(url.allQueryItemValues("1"), expected);
url.removeQueryItem("1");
QCOMPARE(url.allQueryItemValues("1").size(), 2);
QCOMPARE(url.queryItemValue("1").toLatin1().constData(), "z");
#endif
url.removeAllQueryItems("1");
QVERIFY(!url.hasQueryItem("1"));
QCOMPARE(url.queryItemValue("4").toLatin1().constData(), "a b");
QCOMPARE(url.queryItemValue("5").toLatin1().constData(), "&");
QCOMPARE(url.queryItemValue("tex").toLatin1().constData(), "a + b = c");
QCOMPARE(url.queryItemValue("foo bar").toLatin1().constData(), "hello world");
//url.setUrl("http://www.google.com/search?q=a+b");
url.setQuery("q=a+b");
QCOMPARE(url.queryItemValue("q"), QString("a+b"));
//url.setUrl("http://www.google.com/search?q=a=b"); // invalid, but should be tolerated
url.setQuery("q=a=b");
QCOMPARE(url.queryItemValue("q"), QString("a=b"));
}
示例2: track
void Tracker::track( const Tracker::ParameterList& parameters )
{
if (!isValidHit(parameters)) return;
QUrlQuery query;
query.setQueryItems(parameters);
query.addQueryItem(QString("v"), ProtocolVersion);
query.addQueryItem(QString("tid"), m_trackingID);
query.addQueryItem(QString("cid"), m_clientID);
track( query );
}
示例3: setQueryItems
void tst_QUrlQuery::setQueryItems()
{
QFETCH(QueryItems, items);
QUrlQuery query;
QueryItems::const_iterator it = items.constBegin();
for ( ; it != items.constEnd(); ++it)
query.addQueryItem(it->first, it->second);
COMPARE_ITEMS(query.queryItems(), items);
query.clear();
query.setQueryItems(items);
COMPARE_ITEMS(query.queryItems(), items);
}
示例4: toUrl
/*!
* Преобразует канал в 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;
}
示例5: url
QUrl pPaypalButton::url() const
{
QUrl url( mQueryItems.value( QSL( "path" ) ) );
QList<QPair<QString, QString> > queryItems;
foreach ( const QString& key, mQueryItems.keys() ) {
if ( key == QSL( "path" ) ) {
continue;
}
queryItems << qMakePair( key, mQueryItems[ key ] );
}
#if QT_VERSION < 0x050000
url.setQueryItems( queryItems );
#else
QUrlQuery query;
query.setQueryItems( queryItems );
url.setQuery( query );
#endif
return url;
}
示例6: url
//.........这里部分代码省略.........
}
case Part:
{
QJsonObject info = QJsonDocument::fromJson(reply->readAll()).object();
if (!info["success"].toBool() && d->model->rowCount() == 0){
emit stateChanged(info["status"].toInt());
dequeue();
}
QJsonObject data = info["data"].toObject();
for (const QJsonValue &value : data["list"].toArray()){
QStandardItem *item = new QStandardItem;
QJsonObject data = value.toObject();
item->setData(data["title"].toString(), Qt::EditRole);
QString head("http://static.comment.%1/V2/%2?pageSize=1000&pageNo=1");
head = head.arg(Utils::customUrl(Utils::AcFun)).arg(data["danmakuId"].toString());
item->setData(head, UrlRole);
item->setData((task.code + "#%1").arg(d->model->rowCount() + 1), StrRole);
item->setData(File, NxtRole);
d->model->appendRow(item);
}
if (task.state != Part){
emit stateChanged(task.state = Part);
}
if (data["pageNo"].toInt() < data["totalPage"].toInt()){
QUrl url = reply->request().url();
auto arg = QUrlQuery(url).queryItems();
for (auto &p : arg){
if (p.first == "pageNo"){
p.second = QString::number(p.second.toInt() + 1);
break;
}
}
QUrlQuery query;
query.setQueryItems(arg);
url.setQuery(query);
d->remain.insert(d->manager.get(QNetworkRequest(url)));
}
break;
}
case File:
{
acProcess(reply);
break;
}
}
};
auto abRegular = getRegular(QRegularExpression("a(b(\\d+([#_])?(\\d+)?)?)?", QRegularExpression::CaseInsensitiveOption));
d->pool.append({ abRegular, 0, abProcess });
auto ccProcess = [this](QNetworkReply *reply){
Q_D(Load);
Task &task = d->queue.head();
int sharp = task.code.indexOf(QRegularExpression("[#_]"));
switch (task.state){
case None:
{
QString i = task.code.mid(2, sharp - 2);
QString p = sharp == -1 ? QString() : task.code.mid(sharp + 1);
QString url("http://www.%1/play/h%2/");
url = url.arg(Utils::customUrl(Utils::TuCao)).arg(i);
if (!p.isEmpty()){
url += QString("#%1").arg(p);
}
forward(QNetworkRequest(url), Page);
break;
}