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

Mike Chinander chinander at gmail.com
Fri May 3 16:58:33 CEST 2019


On that last line you're indexing a QList which takes an int for its
argument.

https://doc.qt.io/qt-5/qlist.html#operator-5b-5d

On Fri, May 3, 2019 at 9:44 AM Jason H <jhihn at gmx.com> wrote:

> Given the code below:
> QMap<uint, uint> reverseHistogram;
> ...
> QList<uint> reverseKeys = reverseHistogram.keys();
> int foregroundIndex = reverseHistogram.size()-2;           // arg,
> QMap::size() returns signed
> uint foregroundPixels = reverseKeys[foregroundIndex];
> uint foregroundColor = reverseKeys[foregroundPixels];
> uint foregroundColor = reverseKeys[foregroundPixels]; //main.cpp:66:37:
> warning: implicit conversion changes signedness: 'uint' (aka 'unsigned
> int') to 'int'
>
> Where is the "signed" conversion happening?
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190503/5b1eb9c6/attachment.html>


More information about the Interest mailing list