Results 1 to 2 of 2

Thread: QSettings and Windows registry - removing a key

  1. #1
    Join Date
    Jan 2011
    Posts
    32
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QSettings and Windows registry - removing a key

    I have an application which I am using an installer to create an installer package for Windows. As part of the install process, the installer puts a data file into the {localappdata} directory, which varies according to the different flavor of os. In order for my app to know positively where the installer placed this file, the installer writes a key to the registry with the path. Then, when my app starts up, it looks for the key, and if present, sets that value so that it can find the data file.
    After the first run, the application stores this path in its own QSettings object. Therefore, after reading this key, I would like to delete it. That is where I am having a spot of difficulty.
    The key is HKCU/Temp_fsfdb/data_path/"path string"

    I have tried
    Qt Code:
    1. QSettings settings("HKEY_CURRENT_USER", QSettings::NativeFormat);
    2. settings.remove("Temp_fsfdb");
    To copy to clipboard, switch view to plain text mode 
    and
    Qt Code:
    1. QSettings settings("HKEY_CURRENT_USER/Temp_fsfdb", QSettings::NativeFormat);
    2. settings.remove("Temp_fsfdb");
    To copy to clipboard, switch view to plain text mode 
    neither of which have garnered success.

    I have also tried
    Qt Code:
    1. QSettings settings("HKEY_CURRENT_USER/Temp_fsfdb", QSettings::NativeFormst);
    2. settings.beginGroup("Temp_fsfdb");
    3. settings.remove("");
    4. settings.endGroup();
    To copy to clipboard, switch view to plain text mode 
    Again, no joy.

    Would someone be willing to show me the proper way to use remove() or perhaps clear() to accomplish removal of the Temp_fsfdb and it's descendants?
    Last edited by lxman; 29th July 2011 at 19:36. Reason: spelling corrections

  2. #2
    Join Date
    Jan 2011
    Posts
    32
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSettings and Windows registry - removing a key

    For the record, I found what "works." I don't entirely know if this is correct, but it does the job on wine as well as on an XP virtual box that I'm running.

    Qt Code:
    1. QSettings settings("HKEY_CURRENT_USER\\Temp_fsfdb", QSettings::NativeFormat);
    2. QString path = settings.value("data_path").toString();
    3. settings.remove("");
    To copy to clipboard, switch view to plain text mode 
    Last edited by lxman; 29th July 2011 at 20:44. Reason: spelling corrections

Similar Threads

  1. Replies: 1
    Last Post: 24th June 2011, 11:11
  2. reading windows registry
    By bhogasena in forum Qt Programming
    Replies: 3
    Last Post: 26th January 2009, 09:36
  3. Replies: 1
    Last Post: 19th September 2008, 15:43
  4. Accessing Windows Registry
    By musaulker in forum Newbie
    Replies: 1
    Last Post: 29th March 2007, 00:32
  5. [QSettings] Why limiting to plain file or registry ?
    By lauranger in forum Qt Programming
    Replies: 8
    Last Post: 13th September 2006, 14:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.