View Full Version : Issue with isActiveWindow()

George Neil
30th September 2009, 10:59
In the examples\mainwindows\mdi

i tried the following code

QList<QMdiSubWindow *> windows = mdiArea->subWindowList();
foreach (QMdiSubWindow *pSubWindow, windows)
bActive = pSubWindow->isActiveWindow();
bHasFocus = pSubWindow->hasFocus();

I tried with 3 subwindows. Even though only one is active [ie selected], all the subwindows are giving the status as active....Also none of the subwindows are having the focus...Why..?

30th September 2009, 11:58
I'd say this is because those methods are not related to QMdiSubWindow but to the top-level window of your application (which is active). Use QMdiArea::activeSubWindow() to query for the active subwindow.

George Neil
30th September 2009, 13:05
I have to use the code within plugins and there is NO acces to the main application MdiArea....

30th September 2009, 13:10
QMdiSubWindow::mdiArea() and optionally QWidget::parentWidget() if needed.