[Qt-interest] Re : Will QSettings be cached?
Castagne Nicolas
nicolascastagne at yahoo.fr
Tue Dec 15 10:47:08 CET 2009
Hello,
You got it, globally speaking.
QSettings is cached.
QSettings::sync() re-synchronize the in-memory data with the data in the file(s).
Qt executes ::sync() automatically from time to time.
The sync() mechanism is useful when needing to access a QSetting from various processes (not needed when accessing from various threads).
You can access a QSetting from various thread. I would use mutexes though in that case - but I am unsure on this.
Hope this helps.
Nicolas
--- En date de : Mar 15.12.09, donglongchao <donglongchao at 163.com> a écrit :
> De: donglongchao <donglongchao at 163.com>
> Objet: [Qt-interest] Will QSettings be cached?
> À: "qt-interest" <qt-interest at trolltech.com>
> Date: Mardi 15 Décembre 2009, 8h57
> Hi,all
>
> I have a question when I use QSettings.When I create a
> QSettings object by open a configure file,will the content
> of this file be cached in the memory until the destructor of
> the QSettings object?
> If yes,I think I can create a QSettings object as a global
> variable and use it directly and quickly(because they are in
> the memory,not hard disk) anywhere in my app if I want to
> get/set some value,even in different threads.Is it the right
> way?Do I need to use QMutex to protect it?AFAIK,the similar
> thing(I forgot the exact name of it) used to save/read
> configure informations in GTK+ will be cached.
> If not,do I have to write/read them from hard disk every
> time I want to use it?Is there a better and faster way?
> Any suggestion will be appreciated.Thanks a lot in
> advance.
>
> Longchao
>
>
>
>
>
>
> -----La pièce jointe associée suit-----
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
More information about the Qt-interest-old
mailing list