[Qt-interest] How to use QSettings::setPath ?

Stephen Collyer scollyer at netspinner.co.uk
Wed Mar 3 12:32:01 CET 2010


This is with Qt 4.6.1 on Opensuse 11.1

I'm trying to create a QSettings object that stores its data in a custom
location. I have the following code:

class ProgramSettings : public QSettings
{
    public:
        ProgramSettings();
...
};

ProgramSettings::ProgramSettings()
{
    QString config_path;
    <set config path to appropriate path>
    setPath(QSettings::IniFormat, QSettings::UserScope, config_path);
}

However, the program fails to find the settings in the location pointed to
by config_path. Am I misusing this somehow ?

The same class works fine if I allow it to use the defaults with code like:

ProgramSettings::ProgramSettings()
            : QSettings(QSettings::IniFormat,
                        QSettings::UserScope,
                        QCoreApplication::organizationName(),
                        QCoreApplication::applicationName())
{
};

-- 
Stephen Collyer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100303/2c41f175/attachment.html 


More information about the Qt-interest-old mailing list