Created
April 29, 2020 04:31
-
-
Save jniemann66/6103386006c71ddb05abfd2dcdc1a0f3 to your computer and use it in GitHub Desktop.
empty QString key in QMap<QString, T>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"quince" | |
"apple" | |
"bananna" | |
"cherry" | |
"" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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