GPPK
GPPK

Reputation: 6666

QMap Insert only produces (error) 0 for Value and Key

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?

Upvotes: 0

Views: 440

Answers (1)

RobbieE
RobbieE

Reputation: 4350

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.

Upvotes: 1

Related Questions