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

QSettings does not store Null QString correct

XMLWordPrintable

    • Windows

      Hello everybody,

      I need to store a QString. The QString can be a null object (i.e isNull() == true). When I store a null string with QSettings, the string is empty but not a null string. I expect that the isNull property can stored with QSettings.

      #include <QString> 
      #include <QVariant> 
      #include <cassert> 
      #include <QSettings> 
      int main(int argc, char *argv[]) 
      { 
          QString string; 
          assert(string.isNull()); // The QString is null QVariant 
          variant(string); 
          assert(variant.isNull()); 
          assert(variant.toString().isNull()); // The QVariant stores it correctly      
          QSettings settings("MyCompaniy"); 
          settings.setValue("test", variant); // I write the variant 
          variant = settings.value("test"); // I read the variant   
          assert(variant.toString().isNull()); // unexpected crash
          return 0; 
      }
      

       

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

            thiago Thiago Macieira
            fettpet Sev Dw
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes