I for one would rather have .length too, could avoid those nasty function call to make generic javascript functions:
function getLength(obj) { if(obj.hasOwnProperty('length')) return obj.length; if(obj.hasOwnProperty('size')) return obj.size; if(obj.hasOwnProperty('count')) return obj.count; return 0; } Jerome On Tue, Jul 26, 2016 at 4:41 PM, J-P Nurmi <jpnu...@qt.io> wrote: > On Tuesday, July 26, 2016 22:04,Jason H <jh...@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 write quite a bit of JS code (server and mobile) and it seems rather > arbitrary to continue to use count. > > > Specific places: > > All models. DelegateModel, DelegateModelGroup, ListModel, etc. > > It's not that arbitrary. "Count" is used all over in item views and item > models, in C++ and in QML. > > -- > J-P Nurmi > _______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest >
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest