How to make window stay behind other windows ?
-
I'm new in Qt. I have a fairly easy question that i cannot solve myself .
I'm creating 5 windows (desktop, Leftbar, Rightbar, Leftbar, Bottombar, Topbar), i want to desktop window always stay bottom of other 4 window. When i click anywhere on desktop window other windows should continue to stay on top. How can i do this ?
@int main(int argc, char *argv[])
{
QApplication a(argc, argv);Desktop desktop; desktop.show(); Leftbar leftbar; leftbar.show(); Rightbar rightbar; rightbar.show(); Topbar topbar; topbar.show(); Bottombar bottombar; bottombar.show(); return a.exec();
}@
-
Hey there, welcome to Qt!
Check out theses posts :
Have fun!http://www.qtcentre.org/threads/7384-Force-a-QDialog-to-be-the-top-level-Window-and-to-stay-at-this-level
http://qt-project.org/forums/viewthread/1389
http://www.qtforum.org/article/33148/a-modeless-dialog-that-is-always-on-top.htmlsetWindowFlags(Qt::WindowStaysOnTopHint);
-
Thank you for your answer, but when i use
setWindowFlags(Qt::WindowStaysOnTopHint);
on leftbar, rightbar, topbar and bottombar they stay on top of all windows (like when i open documents folder these windows continue to stay on top).
I want these windows stay top of my "desktop" window, not all windows.
-
I would put
Qt::WindowStaysOnBottomHint
on the Desktop window and not worry about the others.http://qt-project.org/doc/qt-4.8/qt.html#WindowType-enum
Good luck
-
I already put
Qt::WindowStaysOnBottomHint on the desktop window,
but it's not working. When i click on desktop window, other windows(Leftbar, Rightbar, Leftbar, Bottombar, Topbar) go bottom of desktop window.
-
For more complex behavior,
You can subclass QWidget and reimplement focusInEvent and/or focusOutEvent to emit your custom signal, then process another Slot in another QWidget.for example, when focus is received on desktop, put another QWidget above (with raise()) or under it(lower()).