本文整理汇总了C++中QJsonValue函数的典型用法代码示例。如果您正苦于以下问题:C++ QJsonValue函数的具体用法?C++ QJsonValue怎么用?C++ QJsonValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QJsonValue函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: QJsonObject
QJsonObject*
SWGNADate::asJsonObject() {
QJsonObject* obj = new QJsonObject();
obj->insert("sec", QJsonValue(sec));
obj->insert("usec", QJsonValue(usec));
return obj;
}
开发者ID:clinique,项目名称:netatmo-swagger-api,代码行数:9,代码来源:SWGNADate.cpp
示例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);
}
开发者ID:fluxer,项目名称:katie,代码行数:12,代码来源:qjsonobject.cpp
示例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);
}
开发者ID:shithead,项目名称:pcbsd,代码行数:9,代码来源:WebSocket.cpp
示例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);
}
开发者ID:AzureAD,项目名称:rms-sdk-for-cpp,代码行数:9,代码来源:JsonObjectQt.cpp
示例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"));
}
开发者ID:EarthDollar,项目名称:earthdollar-qt,代码行数:9,代码来源:qjsonrpcmessage.cpp
示例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));
}
开发者ID:privet56,项目名称:qWebTest,代码行数:56,代码来源:collectmailsesb.cpp
示例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());
}
}
}
开发者ID:e-sensing,项目名称:wtss.tl,代码行数:56,代码来源:server_manager.cpp
示例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;
}
开发者ID:QuantumBytesInc,项目名称:ROAL,代码行数:10,代码来源:controls.cpp
示例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));
}
开发者ID:linuxdeepin,项目名称:libdui,代码行数:10,代码来源:dfontcombobox.cpp
示例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;
}
开发者ID:hzzlzz,项目名称:InteractiveCourse,代码行数:10,代码来源:icquestion.cpp
示例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;
}
开发者ID:oktoshi,项目名称:SOILsafe,代码行数:10,代码来源:etheripc.cpp
示例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;
}
开发者ID:sea-kg,项目名称:reversehash,代码行数:10,代码来源:reversehashd_server.cpp
示例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();
}
开发者ID:clement-nardi,项目名称:pics-dl,代码行数:10,代码来源:config.cpp
示例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);
}
开发者ID:innovive,项目名称:qjson-backport,代码行数:18,代码来源:qjsonobject.cpp
示例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();
}
开发者ID:Apocalypsing,项目名称:MultiMC5,代码行数:54,代码来源:InstanceList.cpp
示例16: qWarning
QVariant SceneModel::data(const QModelIndex &index, int role) const
{
int row = index.row();
if (!index.isValid()) {
qWarning() << "Index" << index << "not valid.";
return QVariant();
}
QList<Scene *> scenes = mNovel->scenes();
if (row > scenes.count()){
qWarning() << "row" << row << " > scene count ("
<< scenes.count() << ")";
return QVariant();
}
Scene *scene = scenes[row];
QJsonArray characterIds;
if (role == Qt::ForegroundRole){
QColor textColor = QColor(0, 0, 0);
Plotline *plotline = scene->plotline();
if (plotline != 0 &&
((255 / 2) > scene->plotline()->getColor().value()))
textColor = QColor(255, 255, 255); // White text.
return QBrush(textColor);
}
if (role == Qt::DisplayRole || role == Qt::EditRole)
return scene->headline();
if (scene->plotline() && role == Qt::BackgroundRole)
return scene->plotline()->getColor();
if (role == HeadlineRole)
return scene->headline();
if (role == ActionRole)
return scene->action();
if (role == PlotlineRole && (scene->plotline() != 0))
return QVariant(scene->plotline()->id());
if (role == CharactersRole){
for(Character *c : scene->getCharacters())
characterIds << QJsonValue(c->id().toString());
return characterIds;
} if (role == PointsOfViewRole) {
for (Character *c : scene->getPointsOfView())
characterIds << QJsonValue(c->id().toString());
return characterIds;
} else if (role == IdRole) {
return scene->id();
}
// qWarning() << "Scene::data - returning general QVariant";
return QVariant();
}
开发者ID:freckles-the-pirate,项目名称:plotline,代码行数:54,代码来源:sceneitemmodel.cpp
示例17: deleteWrappedObject
QJsonValue QMetaObjectPublisher::invokeMethod(QObject *const object, const int methodIndex,
const QJsonArray &args)
{
const QMetaMethod &method = object->metaObject()->method(methodIndex);
if (method.name() == QByteArrayLiteral("deleteLater")) {
// invoke `deleteLater` on wrapped QObject indirectly
deleteWrappedObject(object);
return QJsonValue();
} else if (!method.isValid()) {
qWarning() << "Cannot invoke unknown method of index" << methodIndex << "on object" << object << '.';
return QJsonValue();
} else if (method.access() != QMetaMethod::Public) {
qWarning() << "Cannot invoke non-public method" << method.name() << "on object" << object << '.';
return QJsonValue();
} else if (method.methodType() != QMetaMethod::Method && method.methodType() != QMetaMethod::Slot) {
qWarning() << "Cannot invoke non-public method" << method.name() << "on object" << object << '.';
return QJsonValue();
} else if (args.size() > 10) {
qWarning() << "Cannot invoke method" << method.name() << "on object" << object << "with more than 10 arguments, as that is not supported by QMetaMethod::invoke.";
return QJsonValue();
} else if (args.size() > method.parameterCount()) {
qWarning() << "Ignoring additional arguments while invoking method" << method.name() << "on object" << object << ':'
<< args.size() << "arguments given, but method only takes" << method.parameterCount() << '.';
}
// construct converter objects of QVariant to QGenericArgument
VariantArgument arguments[10];
for (int i = 0; i < qMin(args.size(), method.parameterCount()); ++i) {
QVariant arg = args.at(i).toVariant();
if (method.parameterType(i) != QMetaType::QVariant && !arg.convert(method.parameterType(i))) {
qWarning() << "Could not convert argument" << args.at(i) << "to target type" << method.parameterTypes().at(i) << '.';
}
arguments[i].value = arg;
}
// construct QGenericReturnArgument
QVariant returnValue;
if (method.returnType() != qMetaTypeId<QVariant>() && method.returnType() != qMetaTypeId<void>()) {
// Only init variant with return type if its not a variant itself, which would
// lead to nested variants which is not what we want.
// Also, skip void-return types for obvious reasons (and to prevent a runtime warning inside Qt).
returnValue = QVariant(method.returnType(), 0);
}
QGenericReturnArgument returnArgument(method.typeName(), returnValue.data());
// now we can call the method
method.invoke(object, returnArgument,
arguments[0], arguments[1], arguments[2], arguments[3], arguments[4],
arguments[5], arguments[6], arguments[7], arguments[8], arguments[9]);
return wrapResult(returnValue);
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:53,代码来源:qmetaobjectpublisher.cpp
示例18: QJsonValue
/*
* Build a message to be sent. Uses the right format defined by protocol
* Receive a QJsonObject to be inserted in data field and a message type to insert in the type field
*/
QJsonDocument RFIDMonitorDaemon::buildMessage(QJsonObject dataObj, QString type)
{
QJsonObject rootObj;
QJsonDocument rootDoc;
rootObj.insert("type", type);
rootObj.insert("datetime", QJsonValue(QDateTime::currentDateTime().toString(Qt::ISODate)));
rootObj.insert("data", QJsonValue(dataObj));
rootDoc.setObject(rootObj);
return rootDoc;
}
开发者ID:gustavovaliati,项目名称:rfidmonitor,代码行数:16,代码来源:rfidmonitordaemon.cpp
示例19: QJsonObject
QJsonObject*
SWGComplex::asJsonObject() {
QJsonObject* obj = new QJsonObject();
if(m_real_isSet){
obj->insert("real", QJsonValue(real));
}
if(m_imag_isSet){
obj->insert("imag", QJsonValue(imag));
}
return obj;
}
开发者ID:sigysmund,项目名称:sdrangel,代码行数:12,代码来源:SWGComplex.cpp
示例20: QJsonObject
QJsonObject*
SWGMethodCountryMobile::asJsonObject() {
QJsonObject* obj = new QJsonObject();
toJsonValue(QString("method"), method, obj, QString("QString"));
obj->insert("country_code", QJsonValue(country_code));
obj->insert("phone_number", QJsonValue(phone_number));
return obj;
}
开发者ID:coinsecure,项目名称:plugins,代码行数:12,代码来源:SWGMethodCountryMobile.cpp
注:本文中的QJsonValue函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论