我需要遍歷QMultiHash
並檢查與每個鍵對應的值列表。我需要使用可變的迭代器,以便我們可以從哈希中刪除項目,如果他們符合某些標準。 The documentation沒有解釋如何訪問所有的值,只是第一個。此外,該API僅提供value()
方法。如何獲得特定密鑰的所有值?如何迭代QMultiHash中的所有值()
這就是我想要做的事:
QMutableHashIterator<Key, Value*> iter(_myMultiHash);
while(iter.hasNext())
{
QList<Value*> list = iter.values(); // there is no values() method, only value()
foreach(Value *val, list)
{
// call iter.remove() if one of the values meets the criteria
}
}