本文整理汇总了C++中QJsonValue函数的典型用法代码示例。如果您正苦于以下问题:C++ QJsonValue函数的具体用法?C++ QJsonValue怎么用?C++ QJsonValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QJsonValue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QJsonObject
QJsonObject*
SWGNADate::asJsonObject() {
QJsonObject* obj = new QJsonObject();
obj->insert("sec", QJsonValue(sec));
obj->insert("usec", QJsonValue(usec));
return obj;
}
示例2: QJsonValue
/*!
\internal
*/
QJsonValue QJsonObject::valueAt(int i) const
{
if (!o || i < 0 || i >= (int)o->length) {
return QJsonValue(QJsonValue::Undefined);
}
const QJsonPrivate::Entry *e = o->entryAt(i);
return QJsonValue(d, o, e->value);
}
示例3: QJsonValue
void WebSocket::SetOutputError(QJsonObject *ret, QString id, int err, QString msg){
ret->insert("namespace", QJsonValue("rpc"));
ret->insert("name", QJsonValue("error"));
ret->insert("id",QJsonValue(id));
QJsonObject obj;
obj.insert("code", err);
obj.insert("message", QJsonValue(msg));
ret->insert("args",obj);
}
示例4: QJsonValue
void JsonObjectQt::SetNamedArray(const std::string& name,
const IJsonArray & jsonArray)
{
QJsonObject jo = this->impl_.toObject();
auto other = static_cast<const JsonArrayQt&>(jsonArray);
jo.insert(name.c_str(), QJsonValue(other.impl()));
this->impl_ = QJsonValue(jo);
}
示例5: QJsonValue
QJsonValue QJsonRpcMessage::params() const
{
if (d->type == QJsonRpcMessage::Response || d->type == QJsonRpcMessage::Error)
return QJsonValue(QJsonValue::Undefined);
if (!d->object)
return QJsonValue(QJsonValue::Undefined);
return d->object->value(QLatin1String("params"));
}
示例6: while
void collectmailsesb::handleMailTable(QString h5, QDomElement eTable, QJsonObject* pDay)
{
if(helpers::str_isempty(h5, true))
{
helpers::log("cmailsesb:handleMailTable !h5:'"+h5+"'", LOG_WRN, qApp, 0);
return;
}
QDomElement eTHeadTr = eTable.firstChildElement("thead").firstChildElement("tr");
QDomNodeList leTHeadTds = eTHeadTr.elementsByTagName("th");
QDomElement eTBody = eTable.firstChildElement("tbody");
QDomElement eTBodyTr = eTBody.firstChildElement("tr");
QJsonArray a;
while(!eTBodyTr.isNull())
{
QDomNodeList leTBodyTds = eTBodyTr.elementsByTagName("td");
if(leTHeadTds.size() == leTBodyTds.size())
{
QJsonObject service;
for(int i=0;i<leTHeadTds.size();i++)
{
QString sVal = prettify(leTBodyTds.at(i).firstChild().nodeValue().trimmed());
QString sKey = prettify(leTHeadTds.at(i).firstChild().nodeValue());
if(helpers::str_isnum(sVal, true, true))
{
if(sVal.indexOf('.') > 0)
{
service.insert(sKey, QJsonValue(sVal.toDouble()));
}
else
{
service.insert(sKey, QJsonValue(sVal.toInt()));
}
}
else
{
service.insert(sKey, QJsonValue(sVal));
}
}
a.append(service);
}
else
{
helpers::log("cmailsesb:handleMailTable step3: head <body>:"+QString::number((leTHeadTds.size()))+" != "+QString::number((leTBodyTds.size())), LOG_WRN, qApp, 0);
}
eTBodyTr = eTBodyTr.nextSiblingElement("tr");
}
pDay->insert(h5, QJsonValue(a));
}
示例7: loadSettings
void wtss::tl::server_manager::addServer(const QString &server_uri)
{
QJsonDocument j_doc = loadSettings();
QJsonObject j_object = j_doc.object();
QJsonObject j_servers = j_object.find("servers").value().toObject();
if(!j_servers.contains(server_uri))
{
QJsonObject j_coverages;
QJsonObject j_server;
wtss::cxx::client remote(server_uri.toStdString());
try
{
std::vector<std::string> result = remote.list_coverages();
for(std::string cv_name : result)
{
wtss::cxx::geoarray_t g_array = remote.describe_coverage(cv_name);
QJsonObject j_attributes;
QJsonObject j_coverage;
for(wtss::cxx::attribute_t attribute : g_array.attributes)
{
QJsonObject j_attribute;
j_attribute["active"] = QJsonValue(false);
j_attribute["scale_factor"] = attribute.scale_factor;
j_attribute["missing_value"] = attribute.missing_value;
j_attributes[QString::fromStdString(attribute.name)] = j_attribute;
}
j_coverage["active"] = QJsonValue(false);
j_coverage["attributes"] = j_attributes;
j_coverages[QString::fromStdString(cv_name)] = j_coverage;
}
j_server["active"] = QJsonValue(false);
j_server["coverages"] = j_coverages;
j_servers[server_uri] = j_server;
j_object["servers"] = j_servers;
j_doc.setObject(j_object);
saveSettings(j_doc);
}
catch(const std::exception &e)
{
boost::format err_msg(
"The server %1% could not be added.\n"
"Due to the following error: %2%");
throw exception() << error_description(
(err_msg % server_uri.toUtf8().data() % e.what()).str());
}
}
}
示例8: toJSON
QJsonObject Controls::toJSON()
{
QJsonObject tmp;
tmp.insert("key",QJsonValue(key));
tmp.insert("label",QJsonValue(label));
tmp.insert("name",QJsonValue(name));
tmp.insert("value",QJsonValue(valueASCII));
return tmp;
}
示例9: QJsonValue
void DFontComboBox::addFontItem(const QString &family, const QString &title)
{
QJsonObject nameObj;
nameObj.insert("itemFontFamily", QJsonValue(family));
nameObj.insert("itemTitle", QJsonValue(title));
dcomboBoxModel()->append(nameObj);
// Make the combo boxes always displayed.
view()->openPersistentEditor(dcomboBoxModel()->getModelIndex(dcomboBoxModel()->count() - 1));
}
示例10: QJsonValue
QJsonObject ICQuestion::saveAsJsonObject() const
{
QJsonObject jo;
jo.insert(idTag, QJsonValue(getId()));
jo.insert(typeTag, QJsonValue(getType()));
if (!getChoices().isNull())
jo.insert(choicesTag, QJsonValue(getChoices()));
return jo;
}
示例11: QJsonValue
QJsonObject EtherIPC::methodToJSON(const RequestIPC& request) {
QJsonObject result;
result.insert("jsonrpc", QJsonValue(QString("2.0")));
result.insert("method", QJsonValue(request.getMethod()));
result.insert("id", QJsonValue(request.getCallID()));
result.insert("params", QJsonValue(request.getParams()));
return result;
}
示例12: QJsonValue
void ReverseHashDServer::sendMessageError(QWebSocket *pClient, QString cmd, int id, Error error){
QJsonObject jsonData;
jsonData["cmd"] = QJsonValue(cmd);
jsonData["rid"] = QJsonValue(id);
jsonData["result"] = QJsonValue("FAIL");
jsonData["error"] = QJsonValue(error.message());
jsonData["code"] = QJsonValue(error.codeError());
this->sendMessage(pClient, jsonData);
return;
}
示例13: QJsonValue
void Config::saveWindowGeometry(QWidget *w, QString key){
QJsonObject obj = gui_params[key].toObject();
obj.insert(WINDOW_X, QJsonValue(w->geometry().x()));
obj.insert(WINDOW_Y, QJsonValue(w->geometry().y()));
obj.insert(WINDOW_WIDTH, QJsonValue(w->geometry().width()));
obj.insert(WINDOW_HEIGHT, QJsonValue(w->geometry().height()));
obj.insert(WINDOW_IS_MAXIMIZED, QJsonValue(w->isMaximized()));
gui_params.insert(key,obj);
saveGUIParams();
}
示例14: QJsonValue
/*!
Returns a QJsonValue representing the value for the key \a key.
The returned QJsonValue is QJsonValue::Undefined if the key does not exist.
\sa QJsonValue, QJsonValue::isUndefined()
*/
QJsonValue QJsonObject::value(const QString &key) const
{
if (!d)
return QJsonValue(QJsonValue::Undefined);
bool keyExists;
int i = o->indexOf(key, &keyExists);
if (!keyExists)
return QJsonValue(QJsonValue::Undefined);
return QJsonValue(d, o, o->entryAt(i)->value);
}
示例15: groupFile
void InstanceList::saveGroupList()
{
QString groupFileName = m_instDir + "/instgroups.json";
QFile groupFile(groupFileName);
// if you can't open the file, fail
if (!groupFile.open(QIODevice::WriteOnly| QIODevice::Truncate))
{
// An error occurred. Ignore it.
qDebug("Failed to read instance group file.");
return;
}
QTextStream out(&groupFile);
QMap<QString, QSet<QString> > groupMap;
for(auto instance: m_instances)
{
QString id = instance->id();
QString group = instance->group();
if(group.isEmpty())
continue;
if(!groupMap.count(group))
{
QSet<QString> set;
set.insert(id);
groupMap[group] = set;
}
else
{
QSet<QString> &set = groupMap[group];
set.insert(id);
}
}
QJsonObject toplevel;
toplevel.insert("formatVersion",QJsonValue(QString("1")));
QJsonObject groupsArr;
for(auto iter = groupMap.begin(); iter != groupMap.end(); iter++)
{
auto list = iter.value();
auto name = iter.key();
QJsonObject groupObj;
QJsonArray instanceArr;
groupObj.insert("hidden",QJsonValue(QString("false")));
for(auto item: list)
{
instanceArr.append(QJsonValue(item));
}
groupObj.insert("instances",instanceArr);
groupsArr.insert(name,groupObj);
}
toplevel.insert("groups",groupsArr);
QJsonDocument doc(toplevel);
groupFile.write(doc.toJson());
groupFile.close();
}