Managing keyboard focus in a multi-dock/multi-dialog application.
-
I'm re-designing an application that consists of a main window that contains numerous widgets embedded in QDockWidgets. There is also an image viewer that can run in a QDialog. There is a set of hot keys that run the viewer and these hot keys should work regardless of which dock or widget (with the exception of text entry fields) has focus. The old approach is to set various widgets (table or tree views, for example) have a focus policy of NoFocus. From the standpoint of running the viewer this is all working. However, it leaves the application open to odd behavior. For example, if the user enters data in a QLineEdit but doesn't hit <enter> or <tab> their entry can lost.
The approach to dealing with this has, over the application's lifetime, been a bit piecemeal. The net result being, odd little problems, like the one about, keep cropping up. I would like to get the application in a state that doesn't require band-aids. I'd like to, finally, come up with and efficient approach that takes better advantage of Qt. I've re-read the keyboard focus overview document and have some ideas, but I'm also curious as to other approach to manage keyboard focus in a multi-dock/multi-dialog application.
My first thoughts is to allow widgets their default focus or possibly set them to have a clickFocus focus policy and pass all key press events up to the main window. Are others running into this issue? What are some approaches others have taken?