开发者

How to paint contents in multi-thread using qt?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜