Skip to content

Instantly share code, notes, and snippets.

@jniemann66
Created April 29, 2020 04:31
Show Gist options
  • Save jniemann66/6103386006c71ddb05abfd2dcdc1a0f3 to your computer and use it in GitHub Desktop.
Save jniemann66/6103386006c71ddb05abfd2dcdc1a0f3 to your computer and use it in GitHub Desktop.
empty QString key in QMap<QString, T>
"quince"
"apple"
"bananna"
"cherry"
""
#include <QDebug>
#include <QString>
#include <QMap>
static bool testQMapNullKey()
{
QMap<QString, QString> testMap
{
{"", "quince"}, // you can have an empty QString as a key
{"a", "apple"},
{"b", "bananna"},
{"c", "cherry"},
};
qDebug() << testMap.value("");
qDebug() << testMap.value("a");
qDebug() << testMap.value("b");
qDebug() << testMap.value("c");
qDebug() << testMap.value("x");
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment