[Development] QVariant comparison in Qt6

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


El divendres, 18 de setembre de 2020, a les 2:54:53 CEST, Thiago Macieira va 
escriure:
> On Thursday, 17 September 2020 16:15:47 PDT Bernhard Lindner wrote:
> > Hi!
> > 
> > There was a discussion about the decision to deprecate (remove?) QVariant
> > comparison (<,>) in Qt6 completely.
> > 
> > Has anything changed for Qt6 (especially regarding comparison of equal
> > and/or convertible types)? Is the complete deprecation still the latest
> > decision?
> 
> Yes, it's changed; no, it's not deprecation.
> 
> What's been removed is the conversion. Aside from the numeric types,
> comparing two variants of different types will always result in false. If
> you want to compare across types, convert one to the other's type or to a
> common third type. You know what data you put in there and you should know
> what conversions can be lossy or not.

But i don't what data someone else put it in a QVariant.

The fact that QAbstractItemModelPrivate::isVariantLessThan exists should be 
proof enough that you can't expect my class to know what someone else put 
inside a QVariant, i mean that's basically the defining feature of QVariant "it 
can hold random things for you".

 Is the official Qt position that we should all "copy&paste" 
QAbstractItemModelPrivate::isVariantLessThan into our item model classes that 
need sorting?

Cheers,
  Albert

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