I have a QVariantMap
, which is an alias for QMap<QString, QVariant>
. And I have a function which takes QStringView key
as argument. I want to search a value in the map by the key.
QVariantMap map;
QStringView key;
QVariant v = map.value(key);
But the third line does not compile. Of course I could convert the string view to QString
but this means one extra memory allocation. Is there any way around this which avoids the unnecessary allocation? How to lookup the value by just the string view?