The title pretty much says it all.
I have a QMainWindow which visibility I want to toggle when clicking the tray icon. I'm using this code:
if(!getMainWnd()->isVisible()) {
getMainWnd()->show();
getMainWnd()->raise();
getMainWnd()->activateWindow();
} else {
getMainWnd()->hide();
}
if(!getMainWnd()->isVisible()) {
getMainWnd()->show();
getMainWnd()->raise();
getMainWnd()->activateWindow();
} else {
getMainWnd()->hide();
}
To copy to clipboard, switch view to plain text mode
It works pretty well but there's one problem, when my main window is overlapped by other windows and programs, it's still considered visible, so when I click tray icon, it get hidden.
I want to modify my code to do this:
1. If window is hidden, show it.
2. If window is visible (and on top), hide it.
3. If window is visible but under other windows, raise it.
Can this be achieved with Qt, or do I have to use WinApi, cause I would really want my code to stay multi-platform.
PS. Using isWindowActive, doesn't work, cause when I click tray icon, the window looses focus, so isWindowActive always returns false.
Bookmarks