本文整理汇总了C++中QUrlQuery::setQueryDelimiters方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrlQuery::setQueryDelimiters方法的具体用法?C++ QUrlQuery::setQueryDelimiters怎么用?C++ QUrlQuery::setQueryDelimiters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUrlQuery
的用法示例。
在下文中一共展示了QUrlQuery::setQueryDelimiters方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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());
}
示例2: differentDelimiters
void tst_QUrlQuery::differentDelimiters()
{
QUrlQuery query;
query.setQueryDelimiters('(', ')');
{
// parse:
query.setQuery("foo(bar)hello(world)");
QueryItems expected;
expected << qItem("foo", "bar") << qItem("hello", "world");
COMPARE_ITEMS(query.queryItems(), expected);
COMPARE_ITEMS(query.queryItems(QUrl::FullyEncoded), expected);
COMPARE_ITEMS(query.queryItems(QUrl::PrettyDecoded), expected);
}
{
// reconstruct:
// note the final ')' is missing because there are no further items
QCOMPARE(query.query(), QString("foo(bar)hello(world"));
}
{
// set items containing the new delimiters and the old ones
query.clear();
query.addQueryItem("z(=)", "y(&)");
QCOMPARE(query.query(), QString("z%28=%29(y%28&%29"));
QUrlQuery copy = query;
QCOMPARE(query.query(), QString("z%28=%29(y%28&%29"));
copy.setQueryDelimiters(QUrlQuery::defaultQueryValueDelimiter(),
QUrlQuery::defaultQueryPairDelimiter());
QCOMPARE(copy.query(), QString("z(%3D)=y(%26)"));
}
}
示例3: constructing
void tst_QUrlQuery::constructing()
{
QUrlQuery empty;
QVERIFY(empty.isEmpty());
QCOMPARE(empty.queryPairDelimiter(), QUrlQuery::defaultQueryPairDelimiter());
QCOMPARE(empty.queryValueDelimiter(), QUrlQuery::defaultQueryValueDelimiter());
// undefined whether it is detached, but don't crash
QVERIFY(empty.isDetached() || !empty.isDetached());
empty.clear();
QVERIFY(empty.isEmpty());
{
QUrlQuery copy(empty);
QVERIFY(copy.isEmpty());
QVERIFY(!copy.isDetached());
QVERIFY(copy == empty);
QVERIFY(!(copy != empty));
copy = empty;
QVERIFY(copy == empty);
copy = QUrlQuery();
QVERIFY(copy == empty);
}
{
QUrlQuery copy(emptyQuery());
QVERIFY(copy == empty);
}
QVERIFY(!empty.hasQueryItem("a"));
QVERIFY(empty.queryItemValue("a").isEmpty());
QVERIFY(empty.allQueryItemValues("a").isEmpty());
QVERIFY(!empty.hasQueryItem(""));
QVERIFY(empty.queryItemValue("").isEmpty());
QVERIFY(empty.allQueryItemValues("").isEmpty());
QVERIFY(!empty.hasQueryItem(QString()));
QVERIFY(empty.queryItemValue(QString()).isEmpty());
QVERIFY(empty.allQueryItemValues(QString()).isEmpty());
QVERIFY(empty.queryItems().isEmpty());
QUrlQuery other;
other.addQueryItem("a", "b");
QVERIFY(!other.isEmpty());
QVERIFY(other.isDetached());
QVERIFY(other != empty);
QVERIFY(!(other == empty));
QUrlQuery copy(other);
QVERIFY(copy == other);
copy.clear();
QVERIFY(copy.isEmpty());
QVERIFY(copy != other);
copy = other;
QVERIFY(!copy.isEmpty());
QVERIFY(copy == other);
copy = QUrlQuery();
QVERIFY(copy.isEmpty());
empty.setQueryDelimiters('(', ')');
QCOMPARE(empty.queryValueDelimiter(), QChar(QLatin1Char('(')));
QCOMPARE(empty.queryPairDelimiter(), QChar(QLatin1Char(')')));
QList<QPair<QString, QString> > query;
query += qMakePair(QString("type"), QString("login"));
query += qMakePair(QString("name"), QString::fromUtf8("åge nissemannsen"));
query += qMakePair(QString("ole&du"), QString::fromUtf8("anne+jørgen=sant"));
query += qMakePair(QString("prosent"), QString("%"));
copy.setQueryItems(query);
QVERIFY(!copy.isEmpty());
}