Qt / C++ - how to store configuration data
What is the best way to store application configuration in a Qt ap开发者_JAVA技巧plication?
If You store only list of name-value pairs QSettings class will suffice. It is cross platform and works well.
Check this page for more info:
http://doc.qt.io/archives/qt-4.7/qsettings.html
On the other hand if You have to store data in multiple tables (many params, many rows) I suggest You use Sqlite and QtSQL. Sqlite is ralational database that can be embeded in your application without the need of starting any servers or installing additional software. Sqlite sotres all tables in one *.db file. You can place each user's configuration in his home directory.
This link demonstrates how QtSQL library works:
http://doc.qt.io/archives/qt-4.7/sql-sqlstatements.html
Well, as you're using Qt anyway, why not using QSettings? You can use its default settings to save your configuration in platform specific default locations (e.g. Registry under Windows) or use it to write to classic INI files.
精彩评论