[Interest] Why does QML prefer 'count' over '.length'?
jhihn at gmx.com
Tue Jul 26 22:04:09 CEST 2016
> Sent: Tuesday, July 26, 2016 at 1:57 PM
> From: "J-P Nurmi" <jpnurmi at qt.io>
> To: "interest at qt-project.org" <interest at qt-project.org>
> Subject: Re: [Interest] Why does QML prefer 'count' over '.length'?
> On Tuesday, July 26, 2016 19:02, Jason H <jhihn at gmx.com> wrote:
> > I seem to remember that too. Would it be possible to at least add .length so that we conform to the norm?
> Adding .length to QML "stuff" is not very specific. Where exactly would you like .length to be added? For something like ListView, both .length and .size would be ambiguous, whereas .count is not that easy to misunderstand, is it?
JS uses length on arrays and strings. Anytime you have an array (be it a list, etc) the number of items is denoted as .length
It makes no sense to have Qt use count in similar situations. As Thiago mentioned length, size and count are all analogous in the C++ API, so I don't know how/why they are ambiguous. I write quite a bit of JS code (server and mobile) and it seems rather arbitrary to continue to use count.
All models. DelegateModel, DelegateModelGroup, ListModel, etc.
More information about the Interest