0

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: output Map

Why is this happening? What am I doing wrong?

demonplus
  • 5,613
  • 12
  • 49
  • 68
GPPK
  • 6,546
  • 4
  • 32
  • 57
  • It looks like you're using Visual Studio. Have you installed the plugin correctly? – RobbieE Jun 23 '14 at 13:21
  • I Haven't had any problems with anything else I have done QT-wise, I have also ensured that Core is selected within QT project settings. – GPPK Jun 23 '14 at 13:22
  • This looks like a problem with the VS variable watch, that it is having trouble parsing the contents of the variable. Can you confirm (using QDebug) that the contents of `myMap` are indeed not correct? – RobbieE Jun 23 '14 at 13:26
  • *sigh*. Using QDebug it can access the key and give me the value. I just printed it to console. Can you answer the question with the above & i'll accept? – GPPK Jun 23 '14 at 13:30

1 Answers1

1

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.

RobbieE
  • 4,280
  • 3
  • 22
  • 36