[Qt-interest] QGraphicsView QThread

Alexis Ménard alexis.menard at trolltech.com
Mon Mar 30 20:03:19 CEST 2009


On Monday 30 March 2009 18:03:27 Bas Terwijn wrote:
> hi all,
>
> I am trying for some time to use QGraphicsView in a multi-threaded
> application where in the main thread I create an QGraphicsView object
> and run the event loop while in a seperate QThread I create and and
> change many QGraphicsItems that are to be visualized in the main thread.
> For thread safety I use a mutex to synchronize the (overloaded)
> QGraphicsView::update() method and all changes to the QGraphicsItems.
>
> My approach doesn't work. I find that the QGraphicsView doesn't update,
> even when I send signals which I think should start the
> QGraphicsView::updateScene() from the main thread. I also experience
> core dumps.
>
> Did anybody find a way to use QGraphicsView to visualize QGraphicsItems
> that are changed by a seperate QThread?
>
> Thank you for your time,
> Bas Terwijn

It won't work...QGraphicsView framework is not thread safe. So you can't call 
any functions from your separate thread, it might crash. But what is the point 
to do the changes into your thread, can't your thread emit a signal when it 
finish to compute and then the main thread change the item itself?

>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest

-- 

Alexis Ménard
Software Engineer, Widgets Team 1
Qt Software, Nokia Norge AS, Sandakerveien 116, 0484 Oslo, Norway
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090330/0dbd7ad6/attachment.html 


More information about the Qt-interest-old mailing list