PDA

View Full Version : Changing focus/selection in QtEmbedded with custom input device.



anr78
7th January 2011, 11:56
I have a QtEmbedded application with 8 QPushButtons arranged in a 2x4 matrix. I need to be able to move focus between the buttons, and to check them. My embedded system doesn't have keyboard or mouse, but a custom input device. Based on the input I send up/down/right/left/ok-messages to my GUI, but I'm not sure what to do with them.

Today I use them to generate KeyEvents that I send to my MainWindow. I have set tab order in QtCreator, and using the up/down keys I'm able to move focus. I have not been able to make Qt:Key_Space check a button, though it does just that on my x86-build. I want to be able to use right/left to move between colums as well, and I have no idea how to accomplish that.

I guess an alternative would be to write my own state machine to move focus and check buttons, but if Qt can do much if this job for me, I'd rather not.

Any advice? I'm fairly certain I'm not the first one with this kind of system, so I suspect there's a Known Good Way out there :)

anr78
30th September 2011, 19:54
* delayed bump *

I'm revisiting this problem now. I've made stuff work by sending the joystick events to the visible views, and emitting KeyEvents to the widgets I want. This makes my app have a bunch of messy joystick-handling all over the place. I would like to have a central joystickdriver that emits events to my application and lets Qt take care of telling the focused widgets to "do the right thing".

Is this a good idea, and Should It Work?