Bring window to front -> raise(),show(),activateWindow() don’t work Bring window to front -> raise(),show(),activateWindow() don’t work windows windows

Bring window to front -> raise(),show(),activateWindow() don’t work


try this:

viewer.setWindowState( (windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);viewer.raise();  // for MacOSviewer.activateWindow(); // for Windows

it work in my project ( in my project viewer is QMainWindow): https://github.com/iptton/Rythem .


This problem is specific to Windows.If the active window belongs to some process, then Windows does not allow other processes to change the active Window.

(Do not try the following:https://wiki.qt.io/Qt_project_org_faq#QWidget_::activateWindow.28.29_-_behavior_under_windows)


I did it like this:

{ this->show(); // Restore from systray this->setWindowState(Qt::WindowState::WindowActive); // Bring window to foreground}

assuming "this" is your QMainWindow.Worked like a charm.