[Interest] QMap::keys() / Qt6

Thiago Macieira thiago.macieira at intel.com
Tue Jan 2 22:34:35 CET 2018


On Tuesday, 2 January 2018 15:37:44 -02 Jason H wrote:
> > currently QMap::keys() returns a QList<T>. Since some newer APIs already
> > using QVector, a conversion from QList to QVector is needed which
> > creates a double allocation when using the easy way (with a clazy
> > warning and hopefully a comment in the review).
> > So to avoid this, I have to write some code to put the keys into a
> > QVector. The problems I've with this solutions are
> > 
> >   - everyone needs to write his own function
> >   - it is (maybe) not catched during Qt6 porting, esp. when using auto,
> > 
> > and we do useless conversions
> > 
> > Is it possible to add a helper function for this somewhere (or is it
> > already available) or another easier way?
> 
> I complained about a lack of a generic iterator class back in the spring of
> last year[1]. Thiago seems to have one waiting for Qt6, because as a
> developer, I don't want to to care what kind of iterable you pass to me, I
> just want to iterate on it.

There's a pair iterator in Qt 5 already.

Replacing the main iterator with pair in Qt may never happen, not just because 
of incompatibility, but because of the way that the Standard Library API is 
designed. It requires a reference to a pair, which you can modify, and we 
don't *have* a pair in the first place.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list