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

QString::compare( QString &other, ... ) treats Null and Empty QStrings as equivalent and returns zero.

XMLWordPrintable

    • 5d0b338f4 (dev), 8b0f8ab96 (6.5)

      In other parts of the documentation it is remarked that Null (a QString with no assigned value) and Empty QStrings are treated the same and that only an .isNull() will differentiated between them. Is it desirable that QString::compare(...) also regards them as the same - I guess it could break things if they were to be treated as not comparable.

      If a functional change is not a valid outcome, could the documentation for QString::compare(...) be expanded to include a note that these two different values are treated as if they ARE comparable - it has caught me out in an application where I was not paying attention to whether I was checking for a user entry of an "Empty" string and a different use case where the use had NOT set a value at all - which was being tracked by the entry being a NULL QString...!

      For the record I attach a sample console program that demonstrates this.

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

            docteam Qt Documentation Team
            slysven Stephen Lyons
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes