Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Default mechanism to store information
WhatIf last edited by
I need to store information to disk every time an app is used, a couple of lines, and I want the info to persist between each runs. Is there a better way than creating a file and writing to it?
Also, is the best location to create this file is in the same directory as the executable will reside? But how to know where the executable will reside ahead of time?
No, you should not write in installation directory! Usually your application will not have write access there!
Fot that kind of information you can use http://doc.qt.io/qt-5/qstandardpaths.html#writableLocation with QStandardPaths::AppLocalDataLocation as parameter to get the directory where your application should store such data. You should check at runtime whether this directory exists and create it if not.
See here for more details: http://doc.qt.io/qt-5/qstandardpaths.html
michelson last edited by michelson
You can try
QSettingsas well .