[Interest] QSettings: no settings file
Sensei
senseiwa at gmail.com
Wed Feb 19 16:28:59 CET 2014
Dear All,
I was using QSettings to get all my defaults, but suddenly with Qt 4.8.5
on OSX 10.9.1 it does weird things: it doesn't create the settings file.
This is my very simple code, using a singleton class:
// Save the window geometry
void Settings::setGeometry(const QRect &r)
{
init();
qWarning("SAVING TO %s", qPrintable(instance_->settings_->fileName()));
instance_->settings_->setValue("windows_x", QVariant(r.x()));
instance_->settings_->setValue("windows_y", QVariant(r.y()));
instance_->settings_->setValue("windows_w", QVariant(r.width()));
instance_->settings_->setValue("windows_h", QVariant(r.height()));
}
The output shows correctly this:
SAVING TO /Users/sensei/Library/Preferences/0com.example.app
However, no file is created there:
ls /Users/sensei/Library/Preferences/0*
zsh: no matches found: /Users/sensei/Library/Preferences/0*
I create the QSettings as follows, given the suggestion about submitting
the app to the Mac AppStore in [1]. The getPreferences() function
returns just QString("%1/Library/Preferences").arg(getenv("HOME")).
instance_->settings_ = new QSettings(getPreferences() +
"/0com.example.app", QSettings::NativeFormat);
Am I missing something?
Thanks!
[1]
http://stackoverflow.com/questions/10816958/qt-mac-app-store-application-rejected-for-file-system-requitements
More information about the Interest
mailing list