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

QVariant equal compare not commutative

XMLWordPrintable

      See following code snippet:

      #include <QApplication>
      #include <QDebug>
      
      enum class color {   red,  green, blue };
      
      Q_DECLARE_METATYPE(color)
      
      int main(int argc, char** argv)
      {
          QApplication app(argc, argv);
      
          QVariant v1 = QVariant::fromValue(color::green);
          QVariant v2 = 1;
          qDebug() << (v1 == v2);
          qDebug() << (v2 == v1);
      
          return app.exec();
      }
      

      Output:

      false
      true
      

      I find this behavior strange. Is this on purpose? When yes, why?
      Otherwise, please fix it.

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

            thiago Thiago Macieira
            zack_snyder Zack
            Votes:
            3 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes