简体   繁体   English

在 Qt Creator 中调试与运行。 不同的数值

[英]Debug vs Run in Qt Creator. Different numerical values

I work on C++ Qt project in QtCreator.我在 QtCreator 中从事 C++ Qt 项目。 There is some manipulation with data (for ex. std::double type).对数据进行了一些操作(例如 std::double 类型)。 When I start debug without any breakpoint then my application shows correct data (-8.7357).当我在没有任何断点的情况下开始调试时,我的应用程序会显示正确的数据 (-8.7357)。 But when I run already compiled program I've got (-8).但是当我运行已经编译的程序时,我得到了(-8)。 What could be reason for this situation?这种情况可能是什么原因?

Below is a piece of my json file:下面是我的 json 文件的一部分:

{
...
"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]
]
...
}

Parsing that file:解析该文件:

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;
}

Setting data to the model then show it on screen:将数据设置到 model 然后在屏幕上显示:

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);

I'm using:我在用着:

I am under Linux astra 4.15.3-2-generic OS我在 Linux astra 4.15.3-2-generic OS 下
GCC compiler - gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516. GCC 编译器 - gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516。
cmake version 3.7.2 cmake版本3.7.2
gdb debuger - GNU gdb (Debian 7.12-6) 7.12.0.20161007-git gdb 调试器 - GNU gdb (Debian 7.12-6) 7.12.0.20161007-git

Here is I duplicate the answer from the comments.这是我从评论中复制答案。
My json-file uses '.我的 json 文件使用 '. ' decimal separator. ' 小数分隔符。 Qt uses the information from QSystemLocale ie the locale information from the Operating System. Qt 使用来自 QSystemLocale 的信息,即来自操作系统的区域信息。 Probably GDB debugger uses his own setting.可能 GDB 调试器使用他自己的设置。 That's why I've got correct data while debugging.这就是为什么我在调试时得到了正确的数据。 I changed line in file /usr/share/i18n/locales/ru_RU我更改了文件/usr/share/i18n/locales/ru_RU中的行

decimal_point "<U002C>"

to

decimal_point "<U002E>"

Then I reconfigured locales:然后我重新配置了语言环境:

dpkg-reconfigure locales

and finally restart Qt Creator and it works fine.最后重新启动 Qt Creator,它工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM