[Qt-interest] QGraphicsSvgItems automatically start a new thread?
Girish Ramakrishnan
girish at forwardbias.in
Thu Nov 11 20:10:25 CET 2010
Hi Guido,
On Wed, Nov 10, 2010 at 2:36 PM, Guido Seifert <Wargand at gmx.de> wrote:
> Hi,
> lately I had a strange problem. I use several QGraphicSvgItems and for some
> reason whenever my widget loses focus I got a warning. Something like
> 'Cannot send events to objects owned by a different thread'. For some time I
> was not able to understand what this meant. Simply because I did not send
> any events. Ok, not directly via sendEvent, of course there are events like
> showEvents. focusEvents, and such involved. But this is nothing I can
> influence directly.
>
> What puzzled me even more was that my program is not multi-threaded. No
> QThread or related classes. It took me some time a discover that all
> QGraphicSvgItems I created normally with 'new' where located in a different
> thread.
>
>
This is simply not possible (svg does not use threads) unless the code that
executes 'new QGraphicsSvgItems' is in a different thread. Maybe you are
using QThread without realizing it? Are you using QRunnable, Qt concurrent
or something?
Check by printing the value of QThread::currentThread() and qApp->thread().
They have to be the same, else your code is running is a non-gui thread.
> The only way I found the get rid of this message was:
> 'graphicItem->moveToThread(thread())'.
>
There is something fundamentally wrong in your code :). The above code is
unnecessary.
Girish
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101112/91144357/attachment.html
More information about the Qt-interest-old
mailing list