QToolbar



  • 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.

    Thanks,

    Nuno



  • 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);
    mainToolBar->show();
    

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

    Antonio



  • 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)
    {
    Q_Q(QToolBar);
    Qt::WindowFlags flags = floating ? Qt::Tool : Qt::Widget;

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

    #ifdef Q_WS_MAC
    flags |= Qt::WindowStaysOnTopHint;
    #endif
    }

    q->setWindowFlags(flags);
    

    }
    @

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

    Antonio


Log in to reply
 

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