0

For my logging system I would like to read out a whole registry folder like this:

​QSettings settings​(​"​HKEY_CURRENT_USER​\\​SOFTWARE​\\​MyApp");
QList<Map> values = settings.getAllValuesAndKeys; // this function does not exists

Is there a way to read out all keys and values like this?

Bamp
  • 25
  • 5
  • allKeys() function that returns all the keys from the registery folder, you can use it and then loop over it and read the value for each key – Mina Ashraf Jan 16 '22 at 11:27
  • 1
    take a look at this question https://stackoverflow.com/questions/50189724/reading-registry-value-on-windows-with-qsettings – Mina Ashraf Jan 16 '22 at 11:27

1 Answers1

0

To iterate thoughta settings file, you can use the allKeys() function to retrieve all the keys. Then iterate each key and use settings.value(key) to get the associated value. Finally, add all values inside a QMap, and the QMap to the QList. Repeat this for each config file and you'll get all the key-value pairs for a particular config file in a QMap object and finally the desired record in a QList with each QMap that is associated with each config file read.

QSettings settingsFile("mysettingsfile.ini");

QList<QMap<QString, QVariant>> registryList;
QMap<QString, QVariant> settingMap;

QStringList keys = settingsFile.allKeys();
foreach (const QString &key, keys)
    settingMap.insert(key, settingsFile.value(key));

registryList.append(settingMap);
Flippi96
  • 71
  • 5