[Interest] Why does QML prefer 'count' over '.length'?

Jason H jhihn at gmx.com
Wed Jul 27 16:31:53 CEST 2016

> Sent: Tuesday, July 26, 2016 at 4:41 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 22:04,Jason H <jhihn at gmx.com> wrote:
> > 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
> And in QML you have .length where you'd expect to have it, in JS arrays and strings.
> > It makes no sense to have Qt use count in similar situations.
> Arrays and strings are not exactly similar situations to item views and item models. :)
> > As Thiago mentioned length, size and count are all analogous in the C++ API, so I don't know how/why they are ambiguous.
> The C++ API of the Qt containers. Not item views nor item models. Two entirely different worlds. The length or size of an array is clear, but the length or size of a list view is likely to get associated to the UI element's visual geometry.

I just don't see it. Qt's usage of Height and width are perfectly consistent. Why have a special rule about Qt containers using count() whent he JS containers use length. That's not a potential confusion, that's a real confusion today: 

property variant items: [1, 2, 3, "four", "five"] // this will use length
ListModel{ id: items; ... } // this will use count.

More information about the Interest mailing list