PDA

View Full Version : Frame-by-frame event handling?



QTNovice
28th October 2013, 19:25
So because of some fairly slow stuff going on in the background, I need to have a separate thread that is in communication with the GUI so that the main thread doesn't lock up. What I decided to do was pass stuff from my new thread to the Qt GUI class, then have an event handler for my GUI that handles all the communication. This works very nicely because any time a key is pushed, the cursor moves, or the mouse is clicked, the event handler is called. The problem is that if you're not interacting with the program in any way then the event handler doesn't handle the communication from the thread properly. So, long story short, I'm looking for either a way to setup a signal on the main window of my GUI that is called every frame, a way to setup the event handler to be called every frame, or any number of other solutions that would solve my problem. I simply need to communicate to the GUI from a separate thread and, because it's not thread safe, I can't do that directly, so I need some sort of handler called every frame.

ChrisW67
28th October 2013, 23:32
You use signals and slots to communicate between threads not the event handler protected functions. If the GUI is supposed to update when the thread sends a signal then connect that signal to a slot that does the update. If your GUI needs to update some display on a periodic basic you can use a QTimer.