Qt-如何在多个平台上保存配置文件 [英] Qt - How to save a configuration file on multiple platforms
本文介绍了Qt-如何在多个平台上保存配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写一个Qt应用程序,需要将一些设置保存到用户的配置目录中。
I'm writing a Qt application that needs to save some settings to the user's configuration directory.
我想出了以下代码来获取该文件夹:
I've come up with the following code to get this folder:
#ifdef Q_WS_WIN
path = QDir::homePath() + "/Application Data/Timely";
#else
path = QDir::homePath() + "/.config/Timely";
#endif
在Windows 7上失败,因为Windows 7使用应用程序数据/漫游/ [ YourApp]。如何以跨平台方式获取用户的配置文件夹?我缺少明显的东西吗? (这应该是一个简单的任务)
This fails on Windows 7 cause Windows 7 uses App Data/Roaming/[YourApp]. How can I get the user's configuration folder in a cross-platform way? I'm I missing something obvious? (this is supposed to be an easy task)
推荐答案
取决于要记录的设置,但我建议使用 QSettings 。
Depends on the settings you want to record, but I would suggest to use QSettings.
这篇关于Qt-如何在多个平台上保存配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文