I feel like the documentation for QMap<>::value and QMap<>::values is a bit 
misleading:

 
const T QMap::value(const Key &key, const T &defaultValue = T()) const
Returns the value associated with the key key.

If the map contains no item with key key, the function returns defaultValue. If 
no defaultValue is specified, the function returns a default-constructed value. 
If there are multiple items for key in the map, the value of the most recently 
inserted one is returned.

See also key(), values(), contains(), and operator[]().
QList<T> QMap::values() const
Returns a list containing all the values in the map, in ascending order of 
their keys. If a key is associated with multiple values, all of its values will 
be in the list, and not just the most recently inserted one.

See also keys() and value().

 

Specifically for the part of “value(…)” and “values(…)” that talk about 
“multiple values for a key”. Each key is unique in the QMap so how would I have 
multiple values associated with a key? Maybe I’m just not understanding what is 
trying to be said in the documentation. It looks like this should be in the 
MultiMap<> docs maybe? I bring this up because a young engineer was a bit 
confused by the docs. 

 

Thank You.

--

Mike Jackson

_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to