PDA

View Full Version : Get notification/info about which Widget that has focus?



JK
27th March 2009, 11:48
Hi,
I have a QApplication wich is a screen (GUI) with a lot of widgets (buttons, labels etc) for controlling graphical objects and displaying position information.
I have a problem that when I press a button (for example to rotate an object) and keep it pressed, the focus is moved somewhere else. For the button to work I have to press quickly or use signal Pressed instead of Clicked. This means for example autorepeat is not working since the button will loose focus for some reason!

Is there anyway to ask the QApplication wich widget that has focus currently? Or in some other way get focuschange information from all widgets in an easy way so i can troubelshoot why the activated button loose focus.

BR,
Jocke

vasanth
27th March 2009, 12:06
See this link to know how to check the current widgets focus state.

http://doc.trolltech.com/4.2/qwidget.html#focus-prop

wysota
27th March 2009, 13:25
Reading documentation doesn't hurt you know...

QApplication::focusWidget(), QApplication::activeWindow().