Qt 4.7.3 : Sub menu is not responding for key up/down event sent using QEvent
Dear All,
In my application, when menu with sub menu is open , programmatically sending key up/down event is not working for the submenu.
Sub menu is opened programmatically using following code
and first item of sub menu is also gets selected but after that sending further event is not working for the sub menu.
if the same time (after displaying sub menu) using arrow keys from keyboard change sub menu selections.
Please help if anyone has any idea.
Thanks.
Re: Qt 4.7.3 : Sub menu is not responding for key up/down event sent using QEvent
Are you sending the events to the correct recipient?
Cheers,
_
Re: Qt 4.7.3 : Sub menu is not responding for key up/down event sent using QEvent
If I give sub menu handle then it sends event correctly but then in case if i have more than one sub menu its very difficult to identify which sub menu is currently open because all sub menu returns true for isVisible.
Thanks
Re: Qt 4.7.3 : Sub menu is not responding for key up/down event sent using QEvent
Have you checked hasFocus()?
Cheers,
_
Re: Qt 4.7.3 : Sub menu is not responding for key up/down event sent using QEvent
You are correct, hasFocus returns false.
Sending return key press event to menu, if menu item is submenu it opens sub menu but doesn't set focus. below is the code i used to simulate return key press.
But one more important point is once the sub menu is open, after that sending key event programmatically is not working but at the same time pressing arrow keys on keyboard changes the selection on sub menu.
Thank you for your useful tips but can you suggest me something to set focus on sub menu.
Thanks.
Re: Qt 4.7.3 : Sub menu is not responding for key up/down event sent using QEvent
Interesting.
Normal keyboard handling requires focus, so if navigating the sub menu with the keyboard works it should have focus.
Anyway, if the focus can not be used to determine the currently open sub menu, then you'll have to decide based on which key you have sent.
Alternatively you could try sending the events to the application object and see if its overall key handling code moves focus through the menu hierarchy.
Cheers,
_