Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
6.8.3
-
None
Description
When iterating through a QVariantList to find the index of a certain value I am using QVariant::compare() == QPartialOrdering::Equivalent to find a specific element.
But when the QVariantList contains QColors I cannot find any element indexes because QVariant::compare always returns QPartialOrdering::Unordered.
Here is a simple way to reproduce it:
QColor red1 = "red"; QColor red2 = "red"; qDebug()<<red1<<red2; qDebug()<<cellValue.toString()<<val.toString(); qDebug()<<(red1 == red2); qDebug()<<(QVariant::compare(red1, red2) == QPartialOrdering::Equivalent); qDebug()<<(QVariant::compare(red1, red2) == QPartialOrdering::Greater); qDebug()<<(QVariant::compare(red1, red2) == QPartialOrdering::Less); qDebug()<<(QVariant::compare(red1, red2) == QPartialOrdering::Unordered);
I understand there is no good ways to "sort" colors but I think QVariant::compare should at least return QPartialOrdering::Equivalent in this case
Edit: for now, I simply workaround this by doing val1==val2 because I need a strict equality but there might be cases where QVariant::compare might be more usefull