Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-136938

QVariant::compare always returns QPartialOrdering::Unordered when used with QColor

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 6.8.3
    • Core: Other
    • 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

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            romain.donze Romain Donzé
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes