[Interest] QVariant compare operator

Bernhard Lindner private at bernhard-lindner.de
Sat Apr 18 16:53:04 CEST 2020


Hi!

> > > Relational comparisons with QVariant are deprecated in 5.15 and will be
> > > removed because they are a misfeaure.
> > > Redesign your code so your question does not need to be asked.
> > 
> > Could you please explain why comparing two QVariants is a misfeature?
> 
> Not comparing for equality. Comparing for ordering.
>
> What comes first, QSize(1, 1) or QRegularExpression("^$") ?

Well, if QVariant::canConvert() says right operand can be converted to type of left, then
convert and compare the result. If it can't convert, behavior should be undefined and
qFatal() should be called (or whatever Qt 5.15 prefers to do in detectable cases of
undefined behavior).

-- 
Best Regards,
Bernhard Lindner



More information about the Interest mailing list