I have a QVariantMap whose key is a string and value is an array(of ints or strings)
How do I get the individual elements of the array?
map["key"] has a method toList(). Can I apply that to arrays?
I have a QVariantMap whose key is a string and value is an array(of ints or strings)
How do I get the individual elements of the array?
map["key"] has a method toList(). Can I apply that to arrays?
Yes,
QString first_string_of_key = QVariantMap["key"].toList()[0];
but this is only for reading. Any attempt to write will not work because QVariant will return a copy of the list. Read this post: Assigning to nested QVariantMap
Maybe you can try this if we say that we have an iterator it
moving around the keys:
we could say
if(it.value("key").type()==QMetaType::ByteArray)
std::vector<std::string> vs_array_valus(QVariantMap["key"].value().toArray());
Or direct use as below:
if(QVariantMap["key"].value().type()==QMetaType::ByteArray)
std::vector<std::string> vs_array_valus(QVariantMap["key"].value().toArray());
Hope this Will help.