Petr
Petr

Reputation: 14505

why QList::count() is signed?

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.

Upvotes: 3

Views: 143

Answers (1)

mmonem
mmonem

Reputation: 2841

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++) {}

Upvotes: 2

Related Questions