PDA

View Full Version : QSettings : rename/copy a group recursively



Kouillo
26th November 2012, 13:39
Hi everybody !

I am looking for a way to directly rename (or at least copy recursively) a group in a QSettings (in my case, a Windows registry arborescence).
I found a trick here : http://www.qtcentre.org/threads/46776-QSettings-copy-from-ini-to-xml-Copy-group but using ChildKeys only permit to copy direct keys, of course...

Is there any way to rename a group ?

For instance, I "manually" copy each elements from one path to another, but I will prefer to copy directly the group (in case of future evolutions, adding keys).

Thanks for future answers.

d_stranz
27th November 2012, 21:51
As the QSettings documentation says, you can use the childGroups() / childKeys() methods to recursively traverse a settings hierarchy.

To rename a group, I think you would have to first retrieve the group under the old name, then add it using the new name, then delete the old name. Alternatively, retrieve the entire hierarchy into a tree structure, rename those things you want to rename, then delete the old settings and write out the tree as new ones.

I don't see any direct methods to rename groups or keys.