作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我需要知道 QMap
中的第二个值。 first()
和last()
等函数是无用的。我必须使用迭代器,某种循环吗?
QMap<int, QString> map;
map.insert(1, "Mario");
map.insert(2, "Ples");
map.insert(3, "student");
map.insert(4, "grrr");
最佳答案
如果您找到特定的键或值,您可以这样做:
// Returns 1
int key1 = map.key( "Mario" );
// returns "student"
QString value3 = map.value( 3 );
或者您想遍历 QMap 中的所有项目?
关于c++ - 如何在 Qmap 中查找特定值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25749073/
我是一名优秀的程序员,十分优秀!