[Interest] Class static members access on QThreads

Thiago Macieira thiago.macieira at intel.com
Wed Mar 27 16:09:07 CET 2013


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.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130327/514cd980/attachment.sig>


More information about the Interest mailing list