How to create a "Tool" type window that behaves as a normal window?
-
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.
-
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]; }
-
yes but the Tool window disappears when the app is in the background. how do we turn that part off?
-
yes but the Tool window disappears when the app is in the background. how do we turn that part off?
@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. -
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.
-
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.
@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. -
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/411828Warning: The window needs the Qt::Tool attribut (Qt creates a NSPanel in this case)
since setFloatingPanel method is only avalaible in NSPanel class. -
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
-
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]; }