简体   繁体   中英

Qt / C++ - how to store configuration data

在Qt应用程序中存储应用程序配置的最佳方法是什么?

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 (eg Registry under Windows) or use it to write to classic INI files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM