Cruz
26th June 2014, 02:12
Hello!
I have a main window that has a graphics view that has a graphics scene that has graphics items. A joystick object in the main window polls the joystick and emits signals when needed. I would like to transfer for example a joystick button press to one of the items in the scene, and I don't see a good way to do this. I could connect the joystick signals to standard slots of the scene, or even every item in the scene, but of course I want to use a custom slot, and that gets lost when accessing the scene() pointer. Only an ugly cast would solve this problem and I would lose the generity of my graphics widget. If on the other hand the joystick was handled in the scene, I have the same problem delivering the joystick button press "up" to the graphics widget. I could perhaps use two distinct joystick objects that do the same thing, one in the window and one in the scene, but I would rather not. Is there maybe a better way that I don't see?
Or more generally: How do I get a custom signal through from the view to the scene or the items? And how do I get a custom signal through from the items to the view?
Thanks,
Cruz
I have a main window that has a graphics view that has a graphics scene that has graphics items. A joystick object in the main window polls the joystick and emits signals when needed. I would like to transfer for example a joystick button press to one of the items in the scene, and I don't see a good way to do this. I could connect the joystick signals to standard slots of the scene, or even every item in the scene, but of course I want to use a custom slot, and that gets lost when accessing the scene() pointer. Only an ugly cast would solve this problem and I would lose the generity of my graphics widget. If on the other hand the joystick was handled in the scene, I have the same problem delivering the joystick button press "up" to the graphics widget. I could perhaps use two distinct joystick objects that do the same thing, one in the window and one in the scene, but I would rather not. Is there maybe a better way that I don't see?
Or more generally: How do I get a custom signal through from the view to the scene or the items? And how do I get a custom signal through from the items to the view?
Thanks,
Cruz