[Interest] focus handling in qt

Konstantin Tokarev annulen at yandex.ru
Fri Jul 20 16:27:21 CEST 2012

20.07.2012, 17:43, "pritam.ghanghas at gmail.com" <pritam.ghanghas at gmail.com>:
> On Fri, Jul 20, 2012 at 7:00 PM, Konstantin Tokarev <annulen at yandex.ru> wrote:
>> 20.07.2012, 17:23, "pritam.ghanghas at gmail.com" <pritam.ghanghas at gmail.com>:
>>> Hi All,I was looking at qt code to understand "how focus management code in qt works in case of  keyboard/remote devices".
>>> I have some loose ends here. I am hoping someone with more exposure to these areas can help me out.
>>> 1. I couldn't figure out how qt is able to move focus between buttons in a widget with left/right. I didn't see any code doing that. There was
>>> code in qwidget.cpp that handles tab/backtab but no right/left.
>>> 2. When I enabled directional navigation with QT_KEYPAD_NAVIGATION, it screwed up all default focus handling my QTableView.
>>> Any link to some write up about these areas of qt or guidelines about focus handling in pointer less devices will be extremely helpful.
>> We write keyPressEvent handlers for our widgets (or event filters) and use QWidget::setFocus().
> we have been doing same but this distributed handling is turning out to be error prone. If some robust mechanism is possible, I would like to take advantage of that. Even if its partial. Moreover we have had bugs sometimes when we lost focus with no one having focus. Mostly easy to fix just by looking at new code.
> But recently I had a issue where i am not able to figure out how I lost focus. The target widget gets focus momentarily but then looses focus.  There doesn't seem to be any code in our application that may do that. I tried intercepting all focus in and focus out events at application level to see what is happening. No success as yet. The widget that looses focus is a button inside my own custom dialog. I thought lets have a deeper understanding of "how qt works in this area before deciding something"

Connect your slot to QApplication::focusChanged() and set breakpoint in it.


More information about the Interest mailing list