Remove Qt::WindowStaysOnTopHint flag in linux



  • Hi ! :)

    I'm currently trying to add in my Qt app, a "focus" option with which the user can keep the window on top. On Windows system, no problem, but with Linux and Unity, the flag is not always removed and the window remains on top.

    Here is the code :

    void MainWindow::requestFocus()
    {
       setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
       show();
    }
    
    void MainWindow::releaseFocus()
    {
       setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint);
       show();
    }
    

    I don't know if I really need to add the X11BypassWindowManagerHint flag, it seems to change anything, it removes the window frames, and sometimes it crashes the graphic server.

    I think it's a problem related here : https://forum.qt.io/topic/73740/undoing-setwindowflags Moreover, the multiple addition and suppression of this WindowStaysOnTopHint creates multiple icons in the unity bar and takes more and more time, as if the flags were stacked.

    Thanks for your help !


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Are you using you're own version of Qt or your distribution one ?



  • Hi and thank you for your help.
    I'm using Qt 5.7, so I downloaded it with the online installer : https://www.qt.io/download-open-source/

    Is there a difference between the available online version and the distribution version ?


  • Qt Champions 2016

    @Maluna34

    • Is there a difference between the available online version and the distribution version ?

    Hi a key difference is that sometimes Qt is changed to fit the distro so it can work
    with new windows mangers/desktop such as unity.
    So it works say for Main menu that it wants to move it. etc.
    Such things. So its a customized Qt for integration.

    Sometimes its 100% the same and just another version of Qt. version wise.
    Like Qt5.5


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.