QMap Insert仅为Value和Key生成(错误)0(QMap Insert only produces (error) 0 for Value and Key)

系统教程 行业动态 更新时间:2024-06-14 16:58:30
QMap Insert仅为Value和Key生成(错误)0(QMap Insert only produces (error) 0 for Value and Key)

我在将值插入QMap时遇到问题,我无法弄清楚原因。 我已经剥离了我的代码,只是为了做我想做的工作。 代码如下:

#include <QtCore/QCoreApplication> #include <QString> #include <QMap> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QString string1 = "a"; QString string2 = "b"; QMap<QString,QString> myMap; myMap.insert(string1,string2); return a.exec(); }

这会产生以下地图:

为什么会这样? 我究竟做错了什么?

I am having a problem inserting values into a QMap & I cannot figure out why. I have stripped my code right down to just make what I was trying to do work. The code is below:

#include <QtCore/QCoreApplication> #include <QString> #include <QMap> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QString string1 = "a"; QString string2 = "b"; QMap<QString,QString> myMap; myMap.insert(string1,string2); return a.exec(); }

This produces the following map:

Why is this happening? What am I doing wrong?

最满意答案

这看起来像VS变量监视的问题,它在解析变量的内容时遇到问题。

如果使用QDebug()检查myMap的值,您可能会发现对已正确插入但VS未正确解释内容。

尝试卸载并重新安装VS插件,如果问题仍然存在,请记录Qt的错误,他们在VS插件中的QMap解析脚本可能有问题。

This looks like a problem with the VS variable watch, that it is having trouble parsing the contents of the variable.

If you check the values in myMap using QDebug(), you'll probably find that the pairs have inserted correctly but VS is not interpreting the contents correctly.

Try uninstalling and re-installing your VS plugin and, if the problem persists, log a bug with Qt that their QMap parsing script in the VS plugin might be faulty.

更多推荐

本文发布于:2023-04-15 03:43:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/1648aed61708a36c0bc3435e9a59ee03.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:仅为   错误   QMap   Insert   error

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!