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

QSettings will store an empty QStringList as @Invalid()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.15.2, 6.9.0, 6.9.1
    • Core: I/O
    • None
    • Linux/X11, Windows

      #if 0
      QSettings writer("./settings.ini", QSettings::IniFormat);
      QStringList list;
      QVariant var = list;
      qDebug() << "var = " << var;
      writer.setValue("key", list);
      #else
      QSettings reader("./settings.ini", QSettings::IniFormat);
      QVariant var = reader.value("key");
      qDebug() << "var = " << var;
      #endif


      Why is an empty QStringList stored as @Invalid()? QSettings should ensure that I read the objects I store.

      When I execute these two pieces of code sequentially, the read key is correct.

      When I read the configuration, in order to avoid multiple function calls (such as first using QSettings:: contains() to determine if it exists, and then using QSettings: value() to obtain the value), I will use the following code:

      This bug will cause me to mistakenly believe that the key does not exist, when in fact the key does exist, but it is empty. My business needs to clearly distinguish whether the key does not exist or is empty!

       

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

            thiago Thiago Macieira
            jerry-ojk 帅 鹏飞
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes