[Interest] Operator QMap<uint, uint>[] is casting to int?

Roland Hughes roland at logikalsolutions.com
Sat May 4 14:12:08 CEST 2019


On 5/4/19 5:00 AM, interest-request at qt-project.org wrote:
>> Unless Qt supports negative indexes (like python's [-1]) I would have thought
>> this would be an int. Thanks for catching that everyone.
> I'm assuming you made a typo there and meant to say "uint"? Regardless here's
> the official reason why Qt uses "int" for container indices:
> https://lists.qt-project.org/pipermail/interest/2013-September/008592.html
There are an awful lot of places where Qt uses int when it should be 
uint like when returning the size() of something. It makes for a lot of 
documentation in the embedded system world where every static_cast<>()  
has to be documented in the code and justified in a formal code review 
which produces even more documentation. It also makes for some fancy 
dancing on 32-bit embedded targets where a uint would be big enough to 
hold the size of something but an int falls short.

-- 
Roland Hughes, President
Logikal Solutions
(630)-205-1593  (cell)
http://www.theminimumyouneedtoknow.com
http://www.infiniteexposure.net
http://www.johnsmith-book.com



More information about the Interest mailing list