[Development] Converting types in Qt

Daniel Teske daniel.teske at digia.com
Thu Jul 17 13:33:49 CEST 2014


On Thursday 17 Jul 2014 13:28:10 Jędrzej Nowacki wrote:
> On Thursday 17 of July 2014 10:51:03 you wrote:
> > QVariant::operator== is not symmetric
> > 
> >      QDateTime dateTime = QDateTime::currentDateTime();
> >     
> >     QTime time = dateTime.time();
> >     
> >     qDebug() << (QVariant(dateTime) == QVariant(time));
> >     qDebug() << (QVariant(time) == QVariant(dateTime));
> > 
> > -->
> > false
> > true
> 
> We could make it symmetric, if you want. 
A equals operator that is not symetric is broken. Such a class cannot be 
reliably used in std nor qt containers. Or do you know which way around, 
QList::contains uses the equals operation?

daniel



More information about the Development mailing list