QSetting可以自动加载和生成用户配置文件(ini),方法过程如下:
1、调用QSettings settings(QSettings::IniFormat, QSettings::UserScope, "organization_name", "application_name"),ubuntu系统下会创建/home/user/.config/organization_name/application_name.ini,如果已存在会自动加载;
2、按照普通setting的写法操作;
3、操作后会自动写入相应ini中。
以下为不同系统,对应ini的保存位置:
Platform Format Scope Path
Windows NativeFormat UserScope HKEY_CURRENT_USER\Software\*
SystemScope HKEY_LOCAL_MACHINE\Software\*
IniFormat UserScope %APPDATA%\*.ini
SystemScope %COMMON_APPDATA%\*.ini
Unix NativeFormat UserScope $HOME/.config/*.conf
SystemScope /etc/xdg/*.conf
IniFormat UserScope $HOME/.config/*.ini
SystemScope /etc/xdg/*.ini
Mac OS X NativeFormat UserScope $HOME/Library/Preferences/com.*.plist
SystemScope /Library/Preferences/com.*.plist
IniFormat UserScope $HOME/.config/*.ini
SystemScope /etc/xdg/*.ini