Important: Please read the Qt Code of Conduct -


  • Hi guys,

    I've been trying to get a qtoolbar initially floating in my QMainWindow...

    The toolbar can be docked, either on top or in bottom area, but initially when the user runs the application I would like this toolbar to be floating and in a specific position on screen. Right now, when I start the application always docks at top.

    Does anyone done this? Any help would be appreciated.



  • Hi,

    I just made a test, and I succeeded using this two calls in my MainWindow constructor (after setupUi call):

    mainToolBar->setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);

    I'm not sure if it works 100% of the time, but you can try.


  • thanks, Antonio!

    well, is working now... later on I will try it also on Mac

  • Well, I found this solution looking at the QToolBar source code, qtoolbar.cpp.

    In particular, I found this method:

    void QToolBarPrivate::updateWindowFlags(bool floating, bool unplug)
    Qt::WindowFlags flags = floating ? Qt::Tool : Qt::Widget;

    flags |= Qt::FramelessWindowHint;
    if (unplug) {
        flags |= Qt::X11BypassWindowManagerHint;

    #ifdef Q_WS_MAC
    flags |= Qt::WindowStaysOnTopHint;



    So I guess that you need also to add the flag Qt::X11BypassWindowManagerHint, and, with Mac,
    the flag Qt::WindowStaysOnTopHint.


Log in to reply