Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
调试vs在Qt创建者中运行。不同数值 我在QtCreator从事C++ QT项目。有一些数据操作(例如std::double类型)。当我在没有任何断点的情况下启动调试时,我的应用程序将显示正确的数据(-8.7357)。但当我运行已经编译过的程序时,我得到了(-8)。出现这种情况的原因是什么 下面是我的json文件的一部分: 正在分析该文件: 将数据设置为模型,然后在屏幕上显示: for(unsigned int row=0;rowsetData(model->index(行,0),an.sources[row].x); model->setData(model->index(第1行),an.sources[row].y); model->setData(model->index(第2行),an.sources[row].z); } ... ui->sourcesTableView->setModel(模型); 我正在使用:_C++_Qt_Gcc_Cmake_Gdb - Fatal编程技术网

调试vs在Qt创建者中运行。不同数值 我在QtCreator从事C++ QT项目。有一些数据操作(例如std::double类型)。当我在没有任何断点的情况下启动调试时,我的应用程序将显示正确的数据(-8.7357)。但当我运行已经编译过的程序时,我得到了(-8)。出现这种情况的原因是什么 下面是我的json文件的一部分: 正在分析该文件: 将数据设置为模型,然后在屏幕上显示: for(unsigned int row=0;rowsetData(model->index(行,0),an.sources[row].x); model->setData(model->index(第1行),an.sources[row].y); model->setData(model->index(第2行),an.sources[row].z); } ... ui->sourcesTableView->setModel(模型); 我正在使用:

调试vs在Qt创建者中运行。不同数值 我在QtCreator从事C++ QT项目。有一些数据操作(例如std::double类型)。当我在没有任何断点的情况下启动调试时,我的应用程序将显示正确的数据(-8.7357)。但当我运行已经编译过的程序时,我得到了(-8)。出现这种情况的原因是什么 下面是我的json文件的一部分: 正在分析该文件: 将数据设置为模型,然后在屏幕上显示: for(unsigned int row=0;rowsetData(model->index(行,0),an.sources[row].x); model->setData(model->index(第1行),an.sources[row].y); model->setData(model->index(第2行),an.sources[row].z); } ... ui->sourcesTableView->setModel(模型); 我正在使用:,c++,qt,gcc,cmake,gdb,C++,Qt,Gcc,Cmake,Gdb,我使用的是Linux astra 4.15.3-2-generic操作系统 GCC编译器-GCC(Debian 6.3.0-18+deb9u1)6.3.0 20170516. cmake版本3.7.2 gdb调试程序-GNU gdb(Debian 7.12-6)7.12.0.20161007-git我从评论中复制了答案。 我的json文件使用“.”十进制分隔符。Qt使用来自QSystemLocale的信息,即来自操作系统的区域设置信息。GDB调试器可能使用自己的设置。这就是为什么我在调试时得到了

我使用的是Linux astra 4.15.3-2-generic操作系统
GCC编译器-GCC(Debian 6.3.0-18+deb9u1)6.3.0 20170516.
cmake版本3.7.2

gdb调试程序-GNU gdb(Debian 7.12-6)7.12.0.20161007-git

我从评论中复制了答案。
我的json文件使用“.”十进制分隔符。Qt使用来自QSystemLocale的信息,即来自操作系统的区域设置信息。GDB调试器可能使用自己的设置。这就是为什么我在调试时得到了正确的数据。我更改了文件/usr/share/i18n/locales/ru_-ru中的行


最后重新启动Qt Creator,它工作正常。

由于我们不是魔术师,您能否演示如何使用所引用的数据,并告诉我们为什么一个值应该正确,而另一个值应该正确wrong@RoQuOTriX没什么特别的。我解析了一些json文件,然后在QTextEditor内的屏幕上打印值。我不澄清细节的主要原因是,在这两种情况下,我的做法完全相同。当我进行调试时,它会正常运行,但当我运行编译后的应用程序时,它会将我的值舍入两倍。我认为这是编译或优化问题。请看一看:一个典型的原因是,您有一个单位化变量,它在调试模式下恰好为零,而在运行模式下有一个随机值,因此您会得到不同的结果。@ZabolonkovDmitri我认为这是编译或优化问题。-程序员应该做的第一件事就是不要责怪正在使用的工具。首先要考虑的是它是否是代码中的一个bug。
{
...
"sources": [
    [-8.30000, -1.43300, 0],
    [-8.73575, -1.76287, -0.24404],
    [-8.68767, -1.72513, 0.35267],
    [-8.24991, -1.39526, 0.59671],
    [-7.86225, -1.10313, 0.24404],
    [-7.91233, -1.14087, -0.35267],
    [-8.35009, -1.47074, -0.59671]
]
...
}
Json::Value root;
std::ifstream jsonFile(pathToJsonFile);
jsonFile >> root;
...
Json::Value srsc = root["sources"];
for (Json::Value::ArrayIndex i = 0; i != srsc.size(); i++)
{
   Json::Value src = Json::arrayValue;
   src = srsc[i];

   Antenna::centerPoint cp;
   cp.x = src.get(Json::ArrayIndex(0), Json::Value()).asDouble();
   cp.y = src.get(Json::ArrayIndex(1), Json::Value()).asDouble();
   cp.z = src.get(Json::ArrayIndex(2), Json::Value()).asDouble();
   an.sources[i] = cp;
}
for(unsigned int row = 0; row < an.sources.size(); row++)
{
    model->setData(model->index(row, 0), an.sources[row].x);
    model->setData(model->index(row, 1), an.sources[row].y);
    model->setData(model->index(row, 2), an.sources[row].z);
}
...
ui->sourcesTableView->setModel(model);
decimal_point "<U002C>"
decimal_point "<U002E>"
dpkg-reconfigure locales