[Qt-interest] QObject::moveToThread: Widgets cannot be moved to a new thread

Konrad Rosenbaum konrad at silmor.de
Fri Jul 31 08:32:01 CEST 2009


On Friday 31 July 2009, alexandre.raczynski at technog wrote:
> > Instantiating QWidgets (and all dereived classes) outside the
> > main-thread _doesnt_ make sense! It will probably lead to nasty errors
> > and shouldn't be done in the first place. So there isn't actually a
> > reason to move a widget to the main thread...

> In my use case it makes sense. It does not lead to nasty errors at least
> on Windows XP (Qt 4.5.2 MinGW). I have commented out the isWidget()
> check in QtCore and it works like a charm.

You have been lucky so far. We all have been through this: it works at first 
because luckily no other GUI action happens at the same time, but some user 
will eventually and often trigger errors that you cannot reproduce.

If you really need to trigger a GUI action from outside the main thread, you 
should use signals and do the actual instantiation and all GUI actions 
inside the main thread. Never touch GUI objects outside the GUI thread!

If you decide to not heed our warnings: please don't bother us when these 
errors eventually show up. Thanks.


	Konrad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090731/7a552ce9/attachment.bin 


More information about the Qt-interest-old mailing list