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. How to create a "Tool" type window that behaves as a normal window?
Forum Update on Monday, May 27th 2025

How to create a "Tool" type window that behaves as a normal window?

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 2.3k Views
  • 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.
  • D Offline
    D Offline
    davecotter
    wrote on last edited by
    #1

    I just want a normal window, but with a small title bar like a Tool window. i do NOT want it "always on top" and i do NOT want it to disappear when the app is in the background.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      davecotter
      wrote on last edited by
      #9

      this worked for me:

      void		QtSetFloatAndHide(QWidget *w, bool float_and_hideB)
      {
          NSView		*view	= reinterpret_cast<NSView *>(w->winId());
          NSWindow		*window	= [view window];
          NSPanel		*panel	= reinterpret_cast<NSPanel *>(window);
      
          [panel setHidesOnDeactivate:float_and_hideB];
          [panel setFloatingPanel:float_and_hideB];
      }
      
      1 Reply Last reply
      1
      • M Offline
        M Offline
        mpergand
        wrote on last edited by mpergand
        #2
        QMainWindow w;
        w.setWindowFlags(w.windowFlags()|Qt::Tool);
        

        Works well on Mac, has no effect on Ubuntu.
        As stated in the doc, it's system dependent.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          davecotter
          wrote on last edited by
          #3

          yes but the Tool window disappears when the app is in the background. how do we turn that part off?

          mrjjM 1 Reply Last reply
          0
          • D davecotter

            yes but the Tool window disappears when the app is in the background. how do we turn that part off?

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #4

            @davecotter
            Hi
            Its controlled by the OS/windows manager and outside Qts control.
            On some systems it can still be visible if main app is behind, on some system
            its not.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              davecotter
              wrote on last edited by
              #5

              i'm on a mac, and am converting my carbon app to Qt. in my carbon app, the appearance of the window title bar (ie: whether it is small) is in no way related to the window behavior (ie: whether it hides when the app is in the background). so i'm not convinced this is "controlled by the OS" (even if using Cocoa calls instead of Carbon). Since there IS a way to do it programmatically, i'm looking for how to do it with Qt.

              mrjjM 1 Reply Last reply
              0
              • D davecotter

                i'm on a mac, and am converting my carbon app to Qt. in my carbon app, the appearance of the window title bar (ie: whether it is small) is in no way related to the window behavior (ie: whether it hides when the app is in the background). so i'm not convinced this is "controlled by the OS" (even if using Cocoa calls instead of Carbon). Since there IS a way to do it programmatically, i'm looking for how to do it with Qt.

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #6

                @davecotter
                Yep, there is most likely a native way using mac API.
                Normally one uses Qt::Tool + stay on top as most Os/windows managers respect that
                and you get a tool like window but its not optimal as it then stay on top of all windows.

                https://bugreports.qt.io/browse/QTBUG-34767

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mpergand
                  wrote on last edited by mpergand
                  #7

                  The following code does the trick:

                  void CocoaBridge::unsetFloatingPanel(QWidget *w)
                  {
                      NSView* view=reinterpret_cast<NSView*>(w->winId());
                      NSPanel* window=[view window];
                      [window setFloatingPanel:false];
                  }
                  

                  See my post describing how to use Cocoa in Qt:
                  https://forum.qt.io/post/411828

                  Warning: The window needs the Qt::Tool attribut (Qt creates a NSPanel in this case)
                  since setFloatingPanel method is only avalaible in NSPanel class.

                  1 Reply Last reply
                  1
                  • D Offline
                    D Offline
                    davecotter
                    wrote on last edited by
                    #8

                    i haven't tried these suggestions yet but i will, thank you so much!

                    you understand, that i do NOT want the window to "float", nor do i want it to "hide" when in the background.

                    the ONLY thing i want is for the window to have a small title bar. other than that, it's a completely normal window.

                    is that what the above will accomplish? thanks again!

                    -dave

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      davecotter
                      wrote on last edited by
                      #9

                      this worked for me:

                      void		QtSetFloatAndHide(QWidget *w, bool float_and_hideB)
                      {
                          NSView		*view	= reinterpret_cast<NSView *>(w->winId());
                          NSWindow		*window	= [view window];
                          NSPanel		*panel	= reinterpret_cast<NSPanel *>(window);
                      
                          [panel setHidesOnDeactivate:float_and_hideB];
                          [panel setFloatingPanel:float_and_hideB];
                      }
                      
                      1 Reply Last reply
                      1

                      • Login

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