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

QVariant::operator== between QVariant(0) and QString

    XMLWordPrintable

Details

    • a25644aec (dev), 7d86115a1 (6.5.0), 40f20ed9e (6.5)

    Description

      Comparing a valid QVariant containing an integer value 0 with any QString through operator== returns true.

      If the QVariant contains any other value the comparison produces the expected output.

      The following test

      const QVariant myInt0(0);
      const QVariant myInt1(1);
      const QVariant myString("my string");
      
      qDebug() << myInt0 << myString << (myInt0 == myString) << (myInt0 != myString);
      qDebug() << myInt1 << myString << (myInt1 == myString) << (myInt1 != myString); 

      prints the following lines:

      > QVariant(int, 0) QVariant(QString, "my string") true false
      > QVariant(int, 1) QVariant(QString, "my string") false true 

      Tested also with Qt 6.2.3 and 6.4.2 and here both the comparisons work as expected.

      Attachments

        For Gerrit Dashboard: QTBUG-111867
        # Subject Branch Project Status CR V

        Activity

          People

            peppe Giuseppe D'Angelo
            alef Alessandro Florio
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes