Hi all

I'd like to read the value of a certain key in the registry. Code is easy enough:

Qt Code:
  1. QSettings settings("HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\SERIALCOMM", QSettings::NativeFormat);
  2. QStringList keyList = settings.allKeys();
  3. QString sComPort = settings.value(keyList[0], "").toString();
To copy to clipboard, switch view to plain text mode 

Note that I started with a key string, but as I saw there was something wrong I've tested it with reading the available keys and using that buffer to make sure the key is correct. The problem is that the value is always empty, even though there is a key with a value.

Going deeper into this, the key name is e.g. "/Device/Serial0". And this is where the problem starts. Digging into the QSettings code, value() will call actualKey() which calls normalizedKey(). normalizedKey() returns a string that never starts nor ends with a slash. So it is actually using "Device/Serial0" which doesn't exist!

Can we somehow ask the value without adjusting the key? It seems weird that the Qt lib changes our requested key behind our backs...