[Qt-interest] QWidget and QThread ?

Thiago Macieira thiago.macieira at trolltech.com
Fri Jun 5 12:02:23 CEST 2009


Em Sexta-feira 05 Junho 2009, às 11:56:35, Patric escreveu:
> I have a form, which i generate in a widget using the multiple inheritance
> approach. I need a thread that operates on the data of this widget. I'm
> wondering, is it a good idea to make my widget thread also (i.e. multiple
> inheritance from QWidget and QThread), so it'll be more convinient to
> operate on the data. What do you think about it ?

Hi Patric

You're asking to do two things you can't do:

1) you can't multiply inherit from QObject. Both QWidget and QThread derive 
from QObject, so you can't do that.

2) you can't use any GUI from outside the main thread.

You can work on the data, sure, from any thread. But the GUI updating must be 
done from inside the main thread only. Otherwise, your application will crash.

-- 
Thiago Macieira - thiago.macieira (AT) nokia.com
  Senior Product Manager - Nokia, Qt Software
     Sandakerveien 116, NO-0402 Oslo, Norway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090605/76ab7b60/attachment.bin 


More information about the Qt-interest-old mailing list