[Qt-interest] QObject::moveToThread: Widgets cannot be moved to a new thread
alexandre.raczynski@technog
alexandre.raczynski at technogerma.fr
Fri Jul 31 09:40:46 CEST 2009
Konrad Rosenbaum a écrit :
> 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
I know that I am playing with fire that's why I asked if someone knows
the real technical limitation(s) behind the fact that it is not
recommended to instanciate a widget outside the main-thread (by the way
Qt does not trigger a warning for that).
Alexandre.
More information about the Qt-interest-old
mailing list