Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
4.8.2, 5.1.0 Beta 1
-
None
Description
The main purpose od STL-style API that I see is to make Qt's classes work with generic algorithms (from STL, or custom ones). But this doesn’t work as it should. Qt has some quite important incompatibilities.
Two of them I have encountered just wanting to write a proper lambda-enabled for_each for associative containers are:
- STL’s cbegin is called constBegin (and the same for cend)
- QMap/QHash iterators have nothing in common to STL’s iterators
- STL’s iterator is a ‘pointer’ to a pair, Qt’s is a ‘pointer’ to a value
- Qt’s pointer has key and value methods, while in STL you use first and second members of the pair
// Qt:
it.key(), it.value()
// STL:
it->first, it->second
This means that more advanced custom generic algorithms will fail either on Qt or STL. Or, you need to do some template magic just to differentiate those two and provide the same API for both.