[Development] QVariant comparison in Qt6

Albert Astals Cid albert.astals.cid at kdab.com
Fri Sep 18 10:59:50 CEST 2020


El divendres, 18 de setembre de 2020, a les 10:37:36 CEST, Lars Knoll va 
escriure:
> > On 18 Sep 2020, at 10:28, Albert Astals Cid <albert.astals.cid at kdab.com>
> > wrote:
 
> > El divendres, 18 de setembre de 2020, a les 10:22:16 CEST, Lars Knoll va
> > escriure:
> 
> >> Sorting and equality are two different things. QVariant has never
> >> supported
 a lessThan operator.
> > 
> > 
> > Yes, it has
> > 
> > https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/kernel/qvariant.h?h
> > =5.15#n467
> 
> You’re right. I thought it didn’t support that.
> 
> What is it you need? Just some total ordering of variants? The method you
> mentioned in QAbstractItemModel also only does ordering for some types,
> otherwise falling back to strings.

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.

But i'll understand if you say "it is how it is, either copy 
QAbstractItemModelPrivate::isVariantLessThan or force the users of your 
generic item model classes to provide their own QVariant lessThan operator".

It's not the end of the world, but it's one of those things that was 
convenient in Qt5 and seems it will not be as convenient in Qt6.

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).

Best Regards,
  Albert

 
> Cheers,
> Lars
> 
> 
> > 
> > Cheers,
> > 
> >  Albert
> > 
> > 
> > 
> >> Cheers,
> >> Lars
> >> 
> >> 
> >> Cheers,
> >> Albert
> >> 
> >> --
> >> Albert Astals Cid |
> >> albert.astals.cid at kdab.com<mailto:albert.astals.cid at kdab.com> | Senior
> >> Software Engineer
> > 
> > Klarälvdalens Datakonsult AB, a KDAB Group company
> > 
> >> Tel: Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
> >> KDAB - The Qt, C++ and OpenGL Experts
> >> 
> >> _______________________________________________
> >> Development mailing list
> >> Development at qt-project.org<mailto:Development at qt-project.org>
> >> https://lists.qt-project.org/listinfo/development
> >> 
> > 
> > 
> > 
> > -- 
> > Albert Astals Cid | albert.astals.cid at kdab.com | Senior Software Engineer
> > Klarälvdalens Datakonsult AB, a KDAB Group company
> > Tel: Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
> > KDAB - The Qt, C++ and OpenGL Experts
> > 
> 
> 


-- 
Albert Astals Cid | albert.astals.cid at kdab.com | Senior Software Engineer
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel: Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - The Qt, C++ and OpenGL Experts



More information about the Development mailing list