My QT app has multiple windows and sometimes, even though the windows are already open but burried under other windows, the user will select an option to open one from the mainwindow menubar in which case I want to simply bring it up and make it the current one. Now using QWidget->raise makes this window go on top of all other windows but it doesnt select it and that is what I need to do. I tried QWidget->setFocus but that doesnt do anything. In the mean time I am using a combination of QWidget->close followed by QWidget->show but I would like to know if there is a command to use with ->raise.
I tried:
pMission->raise();
pMission->setFocus(Qt::ActiveWindowFocusReason);
but it didnt work so i used:
pMission->close();
pMission->show();
Have you ever tried QWidget::activateWindow?
From help file, this function is going to
Sets the top-level widget containing this widget to be the active window. An active window is a visible top-level window that has the keyboard input focus.
On MacOS Lion with Qt 4.8.0, raise() was the only one that worked for me. activateWindow() and setFocus() did not.
(I don't have enough karma to make this a comment on Mason's answer)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With