On Freitag, 18. September 2020 17:06:20 CEST Thiago Macieira wrote: > On Friday, 18 September 2020 01:59:50 PDT Albert Astals Cid via Development > > wrote: > > We have a few generic item models and proxy models that implement sorting, > > they did so by using operator< of QVariant. > > > > I want a way to be able to do the same in Qt6 in a way that ideally > > doesn't > > involve having to copy the QAbstractItemModelPrivate::isVariantLessThan > > code. > > Perform an unconditional conversion to string and sort that.
For large models of numerical data, this will completely nuke the performance. Sure, QVariant-construction of integral data isn't free, but it's going to be miles ahead of creating tons of temporary string representations. > In a model, where you're likely to *display* the element, this is probably > the right thing to do, as you don't want to explain to your users why your > list shows items like > > 1 > 10 > 11 > 2 > 3 > 21 > > A few of the above are strings and the others are numbers. It should always > lexicographically sort or use numeric/natural sorting. This wouldn't be an issue if you sort by the integral values instead. > > Maybe making QAbstractItemModelPrivate::isVariantLessThan public and > > clearly defining what it was would be good enough (i mean if it is good > > enough for QAbstractItemModel it could be enough for most of the other > > implementations). > > That's a good idea. Agreed. -- Milian Wolff m...@milianw.de http://milianw.de
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development