[Interest] QMap<> function documentation

Michael Jackson mike.jackson at bluequartz.net
Wed May 25 18:19:52 CEST 2022


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20220525/07060c58/attachment.htm>


More information about the Interest mailing list