[Interest] Class static members access on QThreads

Michael Dougras da Silva micdoug.silva at gmail.com
Wed Mar 27 19:30:29 CET 2013


Em 27/03/2013 12:09, Thiago Macieira escreveu:
> On quarta-feira, 27 de março de 2013 11.20.32, Michael Dougras Silva wrote:
>> I am a newbie in QT, and I have difficulties in using QThreads. What occurs
>> is that i created one class named Logger what functions like a stream to a
>> log file.
>> This class maintains some static attributes (QFile and QTextStream) what
>> refers to a log file. I use this class always I want to write logs, but
>> when I try to use
>> a Logger inside a QThread, the application crash. I cannot use this class
>> Logger inside a Thread? How can I fix this?
> You can use QFile and QTextStream in a thread. What you can't do is use the
> same *objects* from two threads at the same time.
>
> See Qt's definition of "thread-safe" and "reentrant". Those two classes are
> reentrant.
>
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
Thanks.
I will study more about QThreads, QMutex and QMutexLocker and try to 
restructure my class.
If I have success, I will post the solution here.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130327/84a20543/attachment.html>


More information about the Interest mailing list