我需要使用QJsonDocument
将值保存在预设水平以下。 我有以下代码示例:
(...)
gameLevels= {3.67, 7.43, 9.76};
while(gameLevels[i] <= x)
{
for(...)
{
//do something and calculate auxPoints.
}
QString sGL = QString::number(gameLevels[i]);
QString below = "below";
QString points = "pts";
instantPowerPoints.insert(below + sGL+ points , auxPoints);
i++;
(...)
}
emit saveData(QJsonDocument(instantPowerPoints));'
它应该保存如下内容:
"below3.67pts":2
"below7.43pts":6
"below9.76pts":10
但相反的是保存:
"below3":Object
"67pts":2
"below7":Object
"43pts":6
"below9":Object
"76pts":10
我得到的问题是我如何将双打数组保存gameLevels
.但我真的需要将带有点的数字保存为字符串。有没有另一种方法可以在不自动创建对象的情况下保存这样的字符串?
我在QTCreator中使用C++。
这应该对工作
instantPowerPoints.insert(QString("%1 %2 %3").arg(below).arg(sGL).arg(points), auxPoints);