PDA

View Full Version : sorting problem in QSetting set.allkeys() ??



tech4web
14th February 2008, 21:21
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 ?


//for example
QSettings settings;
settings.setValue("a", Qt::white);
settings.setValue("c", QSize(32, 96));
settings.setValue("b", true);
settings.setValue("d", false);

QStringList keys = settings.allKeys();
//instead of a c b d i have a b c d !!

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

thanks

jpn
14th February 2008, 21:35
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...

tech4web
14th February 2008, 22:20
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. :o

tech4web
15th February 2008, 00:39
;)
i use this way ! so orders can take place by %Number :rolleyes:
%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