std::map<QString, std::vector<mapSave>> mapData;打印输出所有值
时间: 2023-12-21 17:30:27 浏览: 129
以下是打印输出所有值的代码示例:
```c++
for (auto iter = mapData.begin(); iter != mapData.end(); ++iter) {
QString key = iter->first;
std::vector<mapSave> value = iter->second;
std::cout << "Key: " << key.toStdString() << std::endl;
for (auto it = value.begin(); it != value.end(); ++it) {
std::cout << " mapSave: {" << std::endl;
std::cout << " id: " << it->id << std::endl;
std::cout << " name: " << it->name.toStdString() << std::endl;
std::cout << " value: " << it->value << std::endl;
std::cout << " }" << std::endl;
}
}
```
其中,`mapData`是一个`std::map`类型的变量,键类型为`QString`,值类型为`std::vector<mapSave>`。`mapSave`是一个自定义的结构体,包含三个成员变量`id`、`name`和`value`。
该代码使用了两个嵌套的循环,外层循环遍历`mapData`中的所有键值对,内层循环遍历每个键对应的值`std::vector<mapSave>`中的所有元素,并打印输出每个元素的三个成员变量`id`、`name`和`value`。
阅读全文
相关推荐
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)