Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-12524

QSettings stored file is deleted on deployment

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • Qt Creator 3.1.1
    • Android Support
    • None
    • Windows 7 64-bit/ Android 4.2.2 MinGW 4.8

    Description

      If a Qt Application is deployed from Qt Creator the settings saved from any previous runs of the application are erased.

      Consider the following code which has to check if the application has run before (the setting is not found, defaults to false) in order to write out some default values to use because the settings are missing after deployment.
      The same code also shows that if the application is restarted on the device without re-deployment, the settings are found and the greeting is correct.

      QSettings settings("MyCompany", "MyApplication");
      
      // if the app has been deployed, the settings are missing so this returns false. If the app is restarted, this returns true.
      bool runOnce = settings.value("runOnce", QVariant(false)).toBool();
      
      if(!runOnce)
      {
          // re-create the necessary settings values since the settings are missing
          settings.setValue("Greeting", "Hello");
          // mark the application as having run already.
          settings.setValue("runOnce", true);
      }
      
      qDebug() << settings.fileName(); // "/data/data/org.qtproject.example.myapplication/files/.config/MyCompany/MyApplication.conf"
      
      qDebug() << settings.value("Greeting").toString(); // "Hello"
      qDebug() << settings.value("runOnce").toBool(); // true
      

      Attachments

        Issue Links

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

          Activity

            People

              dt Daniel Teske
              miketrahearn Mike Trahearn
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes