View Full Version : force QSettings to create .ini file in desired directory
navid
5th December 2009, 12:53
Hi
how can I force QSettings to create .ini file in desired directory.
the following code doesnt work:
QSettings _qsetsettings("ORG_NAME", "APP_NAME");
...
_qsetsettings.setDefaultFormat(QSettings::IniForma t);
_qsetsettings.setPath(QSettings::IniFormat,
QSettings::UserScope,
QDir::currentPath());
_qsetsettings.sync();
_qsetsettings.setDefaultFormat(QSettings::NativeFo rmat);
Regards
navid
wysota
5th December 2009, 13:25
You can pass it a full file path and name where the file should be created.
navid
5th December 2009, 13:41
please one line of code !
wysota
5th December 2009, 13:46
Please look into the docs into the list of constructors for QSettings.
navid
5th December 2009, 13:58
all of the constructors:
QSettings ( const QString & organization, const QString & application = QString(), QObject * parent = 0 )
QSettings ( Scope scope, const QString & organization, const QString & application = QString(), QObject * parent = 0 )
QSettings ( Format format, Scope scope, const QString & organization, const QString & application = QString(), QObject * parent = 0 )
QSettings ( const QString & fileName, Format format, QObject * parent = 0 )
QSettings ( QObject * parent = 0 )
~QSettings ()
I dont want to craete a new qsettings.
I only want to save as .ini, the existing native format ones.
wysota
5th December 2009, 14:13
I think I already told you in the other thread that you can't do that just like that.
navid
5th December 2009, 14:46
with thanks to all of the posts :D
it solved
QString _qsname = "settings.txt";
_qsname = QDir::currentPath()+"/"+_qsname;
QSettings _qstini(_qsname, QSettings::IniFormat);
QStringList keys = _qsetsettings.allKeys();
foreach (QString qstr, keys){_qstini.setValue(qstr,_qsetsettings.value(qs tr)); }
_qstini.sync();
navid
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.