I'm new to GUI programming and multithreading. I am in the process of creating a real-time app that receives information from my car and renders it in some meaningful way. My app is layed out as 3 threads, the GUI (main thread), the rendering thread and the hardware comm thread. Inbetwen the the render and the hardware threads is a shared ring buffer. In the render I have created a timer so that it draws the new interface 20 times a second. I would like the thread to notify the main thread that there is a new screen available and I was thinking a signal/slots method would work the best for this. This gets down to my question. When my render calls a slot, say Screen_Avalable, that is in my main window object in the main thread, does this slot/method get processed in my worker thread or the main thread?
5
votes
Note that it is probably not a good idea to actually draw something on the GUI from any thread other than the GUI thread. Your rendering thread probably should just prepare data to draw and pass it to the GUI thread using a queue or something.
– Sergei Tachenov
In Qt you can't display anything from other than the Gui thread
– Martin Beckett
I was going to draw to a pixmap and then pass the pixmap to the gui thread to be drawn to the screen
– Talguy
Well, that's fine then. Don't know about performance, but thread-wise it's fine I think.
– Sergei Tachenov
2 Answers
4
votes