Polnareff
30th September 2010, 22:49
Hi,
So in my application I need one QSettings file. In Windows I'd rather use my own regular filepath than the default registry path. I'd also like to be able to use this QSettings across my application without needing to specify the file. Using the QT documentation, I first did the following in my main function:
QCoreApplication::setOrganizationName("MyOrg");
QCoreApplication::setApplicationName("MyApp");
QSettings::setPath(QSettings::IniFormat,QSettings: :UserScope,QString(getenv("APPDATA")));
According to the documentation, since I set the organization and app name, when I create an instance without specifying those two, it should use them be default:
QSettings _Settings;
But this doesn't seem to work at all, and I'm not sure where it's saving to. The only time it does actually work is if I specify it each time, as follows:
QSettings _Settings(QSettings::IniFormat,QSettings::UserScop e,"MyOrg","MyApp");
Obviously I don't want to do this every time...
Is there something I'm forgetting, or doing wrong? Or perhaps it's simply not possible to do this...? Thanks!
So in my application I need one QSettings file. In Windows I'd rather use my own regular filepath than the default registry path. I'd also like to be able to use this QSettings across my application without needing to specify the file. Using the QT documentation, I first did the following in my main function:
QCoreApplication::setOrganizationName("MyOrg");
QCoreApplication::setApplicationName("MyApp");
QSettings::setPath(QSettings::IniFormat,QSettings: :UserScope,QString(getenv("APPDATA")));
According to the documentation, since I set the organization and app name, when I create an instance without specifying those two, it should use them be default:
QSettings _Settings;
But this doesn't seem to work at all, and I'm not sure where it's saving to. The only time it does actually work is if I specify it each time, as follows:
QSettings _Settings(QSettings::IniFormat,QSettings::UserScop e,"MyOrg","MyApp");
Obviously I don't want to do this every time...
Is there something I'm forgetting, or doing wrong? Or perhaps it's simply not possible to do this...? Thanks!