c++qtregistryqsettings

How to add/change registry in qt?


I tried

QSettings mSettings; 
mSettings.setValue("HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/USBTOR/Start",   4);

This didn't work.


Solution

    1. Initialize QSettings with registry path (Make sure to use backslash for registry path)

      QSettings settings("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\USBTOR", QSettings::NativeFormat);

    2. Set Value

      settings.setValue("Start", 4);