Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QToolbar
Qt 6.11 is out! See what's new in the release blog

QToolbar

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 5.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nemmartins
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tony
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nemmartins
        wrote on last edited by
        #3

        thanks, Antonio!

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

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tony
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved