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

QSettings: can fail to read values written with Qt5

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.7.2, 6.8.0
    • Core: I/O
    • None
    • macOS 15
    • macOS

    Description

      in our effort to move to Qt6 we came across a problem. Fortunately it seems to be only with special types that this fails.

      So if you run that code with Qt5

      #include <QSettings>
      int main()
      {     
          QSettings s{QSettings::UserScope, "org", "app"};
          QVariantMap newData{{"1", QVariantList{QByteArray("toto")}}};
          s.setValue("toto", newData);
      }  

      and then run this code with Qt6:

      #include <QSettings>
      int main()
      {
          QSettings s{QSettings::UserScope, "org", "app"};
          qDebug() << "HAHA" << s.value("toto").toMap().value("1").toList().constFirst();
      } 
      

       

      You would expect that the value printed is a QByteArray.. but no, it is a QVariantList with 1 item that is the QByteArray.

      So far I was only able to pro that problem if I write a QVariantMap where values are QVariantList.

      Attachments

        1. readmaplist.plist
          0.3 kB
          Thierry Bastian
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            thierryb Thierry Bastian
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes