[Qt-interest] QSettings created in one thread, accessed from another

Girish Ramakrishnan girish at forwardbias.in
Thu Jun 18 05:23:56 CEST 2009


Patric wrote:
> Hello all,
> I have noticed one interesting thing, which I can't explain to myself.
> I have a GUI application with one worker thread. I was working around
> with QSettings recently, my QSettings settings object was initialized in
> the constructor of my worker thread. And when I was trying to use it
> from that thread... it was not working. Anyway, I moved the creation of
> my settings object in my run method. Now it works.
> But does anyone have an idea why it was not working when it was
> initialized in the main thread ? QSettings is not event driven.
> Also I have another object initialized in the constructor of the worker
> thread (it's an instance of a class created by me), which I'm accessing
> from it and there is no problem.
>  

QSettings is event driven. The writes/flush are asynchronous; changes
are committed using an event posted to itself.

And you should not create QSettings in one thread, and use it in another.

Girish



More information about the Qt-interest-old mailing list