PDA

View Full Version : Is there a way to know the current widget of the app ?



tonnot
29th September 2010, 15:53
I would want to know if I can determine in a Class_B who is the active or current widget of my application.
By other side, supposing my app is showing a form, any way to know the 'toplevel' parent ?
Thanks

Zlatomir
29th September 2010, 16:03
If by active you mean the widget which receives user input, than you have hasFocus() (http://doc.trolltech.com/latest/qwidget.html#focus-prop)
And QObject has (QWidget is derived from it so it has this too) parent() (http://doc.trolltech.com/latest/qobject.html#parent) member function which returns a pointer to the parent object.

Lykurg
29th September 2010, 16:29
You can also have a look at QApplication::focusWidget().

wysota
29th September 2010, 16:37
any way to know the 'toplevel' parent ?
QWidget::window()

tonnot
29th September 2010, 19:21
Thanks to everybody