I'm very new to QT, but I need to write an interface to a DMX lighting controller that I've built, and QT seemed like the easiest way. I'm really enjoying it so far, but I don't quite understand Threads.
Here's what I'd like to do:
The program is normally controlled by the mouse/keyboard, but there is an option to control it with a usb joystick.
When the user clicks the "enable joystick" check box, a joystick thread should be started (I believe this is the most efficient way, but if not, I'd be happy to receive suggestions). This joystick thread should check the status of the joystick every 2ms or so, and when there is a change, it should notify the rest of the program.
I've gotten the joystick thread to start when I click the start checkbox, and it outputs the joystick state to the terminal perfectly, so I know that is working. However, I dont know how to send it back to my Main thread.
I tried calling a main thread function from within the joystick thread, and having that function update the display, but the program crashed with about 60, "QPixmap: It is not safe to use pixmaps outside the GUI thread"s. I think this is because the function is still being run within the joystick thread, and it crashes when it tries to redraw the screen.
What I'd really like is for the joystick to emit a signal on every change of state, just like a widget. And then I'd like to have a series of slots to receive them, but doing that across threads is beyond me.
Any suggestions anyone can give would be most welcome.