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

QVariant::operator==() returns true for QVariant(QVariant::Int) and QVariant(0)

    XMLWordPrintable

Details

    Description

      Consider the following example:

      QVariant var1(QVariant::Int);

      int intval = 0;
      QVariant var2(intval);

      qDebug() << (var1 == var2); // prints true
      qDebug() << (var1.isNull() == var2.isNull()); // prints false

      Since var1 is null, it is expected that it is not equal to the non-null var2.

      DECISION: This is a known behavior of QVariant, which interprets == in a "fuzzy" way (a bit like == in JavaScript). Unfortunately, we cannot change this in Qt 4.x without breaking existing applications, but will consider this for Qt 5. I hope we can do it then, because I dislike QVariant's == behavior just as much as you do.

      Attachments

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

        Activity

          People

            stormols Marius Storm-Olsen
            sthomass Stian Sandvik Thomassen (closed Nokia identity) (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes