Results 1 to 4 of 4

Thread: sorting problem in QSetting set.allkeys() ??

  1. #1
    Join Date
    Dec 2007
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default sorting problem in QSetting set.allkeys() ??

    i want to read some db names from a config file and they are ordered.
    but when i read them with allkeys , the data that i have now is sorted by allkeys!
    what can i do ?

    Qt Code:
    1. //for example
    2. QSettings settings;
    3. settings.setValue("a", Qt::white);
    4. settings.setValue("c", QSize(32, 96));
    5. settings.setValue("b", true);
    6. settings.setValue("d", false);
    7.  
    8. QStringList keys = settings.allKeys();
    9. //instead of a c b d i have a b c d !!
    To copy to clipboard, switch view to plain text mode 

    but i need a c b d ???
    any idea.

    thanks
    Last edited by jpn; 14th February 2008 at 22:29. Reason: missing [code] tags

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: sorting problem in QSetting set.allkeys() ??

    I'm afraid you can't AND you shouldn't rely on the order settings are saved. As you know, the storage behind QSettings might be an INI file, XML preferences file or Windows registry. I'd suggest adjusting your design not to care about the order...
    J-P Nurmi

  3. #3
    Join Date
    Dec 2007
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: sorting problem in QSetting set.allkeys() ??

    Quote Originally Posted by jpn View Post
    I'm afraid you can't AND you shouldn't rely on the order settings are saved. As you know, the storage behind QSettings might be an INI file, XML preferences file or Windows registry. I'd suggest adjusting your design not to care about the order...
    I THINK SO .
    may be i can have a another value and give them a number for they order.

  4. #4
    Join Date
    Dec 2007
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: sorting problem in QSetting set.allkeys() ??


    i use this way ! so orders can take place by %Number
    %01
    %00
    %02

    when i write to config :setting.setValue("/Database/"+dbName.prepend(row)); %01Name
    when i read from config :dbnames.at(row).remove(0,1) Give Me Name

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.