[Interest] How to make the QString "10" behind "9" in QMap's key order

Thiago Macieira thiago.macieira at intel.com
Mon Apr 9 21:59:06 CEST 2018


On Monday, 9 April 2018 10:44:06 PDT Roland Hughes wrote:
> On 01/08/2018 06:26 AM, Mark Gaiser wrote:
> > You might want to look into std::map[1] as well. It allows setting a
> > compare function, QMap doesn't.
> > Going that route is most likely more efficient as your inserts will be
> > sorted, no need to do std::sort afterwards.
> 
> Jumping into this one late, but, is there any particular reason QMap
> doesn't allow overriding or supplying a comparison method? Has a feature
> request already been filed.

Derive from QString and use that as your key type, providing your operator< or 
qLess.

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






More information about the Interest mailing list