views:

247

answers:

1

Hi All,

I want to paint contents in a multi-thread application using qt.

The qt runs in the main thread. I have a thread B to generate paint tasks and to send tasks to qt main thread. Currently, I call "mywidget.update" in thread B, the "mywidget.paintEvent(..)" will be triggered in main thread.

My problem is that I cannot pass any own data to "mywidget.paintEvent(..)" by using the method update. Currently I use a queue to store the data, I want to paint, and read it from paintEvent. But I have to synchronize this queue.

Is there any better way? Such as registering an own paint event. It will be very appreciated, if someone you post simple example or some links.

+1  A: 

Hi.

I didn't read that article in its fullest myself, but from the title it seems like you may find some ideas there:

http://labs.trolltech.com/blogs/2010/01/21/qt-graphics-and-performance-generating-content-in-threads/

Cheers.

dpimka