Get active child widget
-
Hi guys,
I have QWidget derrived as main widget of application. Also has inside some QDockWidget derrived widgets. How can I get an active/focused dock widget from main widget at this moment?Qt 5.15
Thanks a lot!
-
Hi guys,
I have QWidget derrived as main widget of application. Also has inside some QDockWidget derrived widgets. How can I get an active/focused dock widget from main widget at this moment?Qt 5.15
Thanks a lot!
QDockWidgets normally live inside a QMainWindow dock area when they are not floating, so the nature of your program is a little bit unclear.
QWidget::focusWidget() or QApplication::focusWidget() will tell you where input focus is. If that is inside (a descendant child) one of your dock widgets then you have your answer.
-
QDockWidgets normally live inside a QMainWindow dock area when they are not floating, so the nature of your program is a little bit unclear.
QWidget::focusWidget() or QApplication::focusWidget() will tell you where input focus is. If that is inside (a descendant child) one of your dock widgets then you have your answer.
Adding to @ChrisW67:
QApplication::focusWidget()
tells you the widget (if any), that currently gets input focus.widget->focusWidget()
isn’t static, has to be called on a widget. It returns what has focus, ifwidget->window()
got activated.