Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to clean up `QSettings` registry entries (Qt 5 on Windows)

Qt stores QSettings values in the windows registry: https://doc.qt.io/qt-5/qsettings.html

Users normally expect an application to remember its settings (window sizes and positions, options, etc.) across sessions. This information is often stored in the system registry on Windows, and in property list files on macOS and iOS. On Unix systems, in the absence of a standard, many applications (including the KDE applications) use INI text files.

I wish to delete those entries if I un-install my Qt App. Is there an easy way to do this, without explicitly deleting all values. I am asking about a Qt function to delete all values for my particular application.

like image 376
Horst Walter Avatar asked Oct 20 '25 10:10

Horst Walter


1 Answers

If you initialise the QSettings object with the company and application name or using the default constructor, you can use the method clear()

Example:

QSettings settings;
settings.clear();

Alternatively, you can also try:

QSettings settings(QSettings::SystemScope, "Org", "App");
settings.clear();
like image 50
Waqar Avatar answered Oct 22 '25 23:10

Waqar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!