[Development] Converting types in Qt

Jędrzej Nowacki jedrzej.nowacki at digia.com
Thu Jul 17 13:28:10 CEST 2014

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. My recommendation is to not use the 
comparison at all. If you want more "features" of QVariant you can look into 
isNull() this is a perfect randomizer :P. The whole discussion took wrong 
direction. I didn't want to discuss QVariant API, which is not fixable, even 
Qt6 would not help, to much staff depends on it. 


More information about the Development mailing list