Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why QList::count() is signed?

Tags:

qt

Why is it returning a signed integer? Is it ever possible for it to be negative? Documentation doesn't explain this, see http://qt-project.org/doc/qt-4.8/qlist.html#count-2

I know that .Net does the same for its Count property, but they do it because of CIL as some other languages don't support unsigned type.

like image 803
Petr Avatar asked Feb 06 '26 10:02

Petr


1 Answers

For simplification because Qt is a cross platform and has binding to Python, etc.

Also because when comparing signed and unsigned variables in conditional statements during loops, for example, can generate warnings ins some compilers because the first option for programmers to have an i iterator is to make it int like:

...
for (int i = 0; i < theQList.count(); i++) {}
like image 124
mmonem Avatar answered Feb 09 '26 12:02

mmonem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!