Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[Solved]How to make always top window



  • I want to know how to make the widget which always keep top like TaskManager
    whenever active window switches to any window.

    Please advise me!



  • @setWindowFlags(Qt::WindowStaysOnTopHint);@



  • Thank you for your quick response!
    I succeeded^^
    So this problem is solved.



  • Sorry but When I used FramelessWindowHint,
    my Widget can't keep "StaysOnTop".

    How should I do ? please teach me!



  • The Qt documentation for Qt::WindowStaysOnTopHint says:

    bq. Informs the window system that the window should stay on top of all other windows. Note that on some window managers on X11 you also have to pass Qt::X11BypassWindowManagerHint for this flag to work correctly.

    If you are on X11 try it



  • bq. Sorry but When I used FramelessWindowHint,
    my Widget can’t keep “StaysOnTop”.

    How should I do ? please teach me!

    This work for me (windows xp)
    this->setWindowFlags(Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint);

    maybe try the tips of mcosta if you're on x11.



  • Thank Mr stuk and mcosta for your kind reply!

    I succeeded in making Frameless and StaysOnTop window.

    My fault is that I called setWindowFlags twice for FramelessWindowHint and WindowStaysOnTopHint respectively.

    I apologize for my poor knowledge.

    So this issue is solved.



  • On a similar vein, from the main app I'm opening up a small dialog box by creating a QWebView.

    By default its in the background I wanted it to show up on the foreground so I set the WindowStayOnTop flag, however I don't want it to always stay on top, just when its first created and then act like a normal window afterwards.

    How do I achieve this?



  • really good answer, but I want more, if I want the widget won't be stay on top when i switch to other application, such as Chrome/Visual Studio, how to do that, that means, I want that widget only stay TOP in-application.



  • [quote author="lygstate" date="1387250539"]really good answer, but I want more, if I want the widget won't be stay on top when i switch to other application, such as Chrome/Visual Studio, how to do that, that means, I want that widget only stay TOP in-application.[/quote]

    I'm looking for the same thank you! Anyone knows how to do it?

    Thanks!


Log in to reply