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 ow开发者_JAVA技巧n paint event. It will be very appreciated, if someone you post simple example or some links.
I didn't read that article in its fullest myself, but from the title it seems like you may find some ideas there:
http://blog.qt.io/blog/2010/01/21/qt-graphics-and-performance-generating-content-in-threads/
Cheers.
精彩评论