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

QStandardItemModel claims that empty string ("") is null

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P4: Low
    • None
    • 4.8.0, 5.1.1
    • Widgets: Itemviews
    • None
    • Windows

    Description

      QStandardItemModel sets the string values for an empty string and a null string so that they can't be distinguish. The QStandardItemModel::setData() function does not see difference with QString() and QString::fromLatin1("") and thus it's not setting the data in the following code snippet:

      QStandardItemModel model(1, 1);
      QModelIndex index = model.index(0, 0);

      bool ok1 = model.setData(index, QString());
      bool ok2 = model.setData(index, QString::fromLatin1(""));
      bool shouldBeFalse = model.data(index).toString().isNull();

      This makes it impossible to distinguish between an empty and a null string.

      Attachments

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

        Activity

          People

            stephen.kelly Stephen Kelly (Unused account) (Inactive)
            qtcomsupport Qt Support
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes