Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt - How to save a configuration file on multiple platforms

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

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)

like image 909
Raphael Avatar asked Dec 02 '22 03:12

Raphael


1 Answers

Depends on the settings you want to record, but I would suggest to use QSettings.

like image 97
tibur Avatar answered Dec 14 '22 22:12

tibur