当前位置:   article > 正文

Qt之QSetting读写ini文件_使用qsetting写ini文件

使用qsetting写ini文件
const QString APP_CONFIG_PATH=QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
  1. QString CommonAPI::readIni(const QString &fileName,const QString &key)
  2. {
  3. QString value;
  4. QString filePath=APP_CONFIG_PATH+"/"+fileName;
  5. QFile file(filePath);
  6. if(file.exists())
  7. {
  8. QSettings *configIniRead = new QSettings(filePath, QSettings::IniFormat);
  9. if (configIniRead)
  10. {
  11. value = configIniRead->value(key).toString();
  12. delete configIniRead;
  13. configIniRead = nullptr;
  14. }
  15. }
  16. return value;
  17. }
  1. void CommonAPI::writeIni(const QString &fileName,const QString &key,const QString &value)
  2. {
  3. if(!createDir(APP_CONFIG_PATH))
  4. {
  5. return;
  6. }
  7. QString filePath=APP_CONFIG_PATH+"/"+fileName;
  8. QSettings *configIniWrite = new QSettings(filePath, QSettings::In
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/300206?site
推荐阅读
相关标签
  

闽ICP备14008679号