×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    22

    delete QSettings when uninstalling Qt application

    Hello,
    How I can remove automatically the data of QSettings when uninstalling application?

    (the QSettings is stored in their default location by using:

    Code:
    QSettings setting(“Company", "MyApplication");
    QVariant value = 10;
    setting.setValue("Engine/TimeOutPeriod", value);
    )
    Last edited by kenouz1234; 2011-01-11 at 16:59.

  2. #2
    Registered User
    Join Date
    Feb 2010
    Posts
    210

    Re: delete QSettings when uninstalling Qt application

    Code:
    settings.clear();
    Will clear all of the data from the settings file.
    Cheers,
    Jon

  3. #3
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: delete QSettings when uninstalling Qt application

    Of course, you need to somehow automatically run that during app removal.

  4. #4
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    286

    Re: delete QSettings when uninstalling Qt application

    If you store the settings file in your private directory (use user scope for settings) they will be automatically deleted. For system scope this becomes issue.
    We had discussion about this, thought there was a bugreport even.. http://bugreports.qt.nokia.com/browse/QTBUG-16229

  5. #5
    Registered User
    Join Date
    Jul 2009
    Posts
    37

    Re: delete QSettings when uninstalling Qt application

    The private dir fixes the issue on 5th and ^3. But it doesn't work on 3rd (Qt4.6.3 or Qt4.7.3)

    Code:
    QSettings *settings;
    settings = new QSettings(QApplication::applicationDirPath().append(QDir::separator()).append("set.ini"), QSettings::IniFormat);
    settings->setValue("test",1);
    While the app is running the value "1" can be read:
    settings->value("test", 0)
    After restarting the app, the value is gone.
    The above code works fine on 5th and ^3.

    Tried stuff like:
    Code:
    QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, apppath);
    No luck.

  6. #6
    Registered User
    Join Date
    Jul 2009
    Posts
    37

    Re: delete QSettings when uninstalling Qt application

    Solved.
    Simply made a subdir in the private folder and store the settings file there.

    Code:
        //set Settings file path
        QString thePath = QApplication::applicationDirPath().append(QDir::separator()).append("set");
        if (QDir(thePath).exists())
        {
            settings = new QSettings(thePath.append(QDir::separator()).append("set.ini"), QSettings::NativeFormat);
        }

Similar Threads

  1. Qt Persistent store: QSettings
    By bobford in forum Qt
    Replies: 1
    Last Post: 2011-01-10, 10:26
  2. Replies: 3
    Last Post: 2010-10-29, 14:14
  3. Replies: 14
    Last Post: 2010-02-16, 11:07
  4. Delete file while uninstalling
    By santu.paul@gmail.com in forum Symbian
    Replies: 5
    Last Post: 2009-02-06, 06:52

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×