Widgets in window title Qt - c++

Is in Qt something like GTK.headerbar or any other possibility to add wiget (button for example) in window title?
Thanks in advance.

Short answer is 'no', Qt doesn't implement any kind of window decorations (except QWS which is a different story).
In Linux the title bars (window decorations) are carried by Window Managers, like Metacity or Compiz. Windows and OSX use their own window decorations. Qt has almost no control over what happens on the window title bars.
Gnome3/GTK3 (and not Gnome2) allows you to use widgets in the title bar but it's not the case for many other Desktop Environments / Window Managers. Your options are:
Use the API provided by the window manager / OS
Pros: native look.
Cons: you need to maintain separate implementation for each OS / DE. Not all support doing such.
Hide window decorations and implement you own
Pros: code once, use everywhere. Google Chrome and Vivaldi do that, for example.
Cons: you need to implement window resize and move
Use an overlay widget on top of the system title bar that will always follow the window
Pros: pretty much straightforward to do but I don't recommend it.
Cons: the widget will always lag when moving the main window. Native look still has to be implemented. Take into account that user can switch the theme and the widget will look odd.

Related

How to minimize a frameless window which has been set size to fixed by method setFixedSize in Qt?

How to minimize a frameless window which has been set size to fixed by method setFixedSize in Qt?
Hi,
I'm using C++ code to make a Qt application. I set the window to frameless by
this->setWindowFlags(Qt::FramelessWindowHint);
So I can't click the minimize button support by Operating System and I made a customed one. But, when I want to use
this.showMinimized();
I found that it can't work with window which has been set fixed size by
this.setFixedSize(width, height);
So my question is, is there some other ways to make the window minimized which can be used by a window that set fixed size?
This is almost definitely not what you are looking for, but most if not all modern operating systems contain a minimize-all keyboard shortcut or show desktop button. You may have the button on your task bar, if you have one. If not, try windows-key+d or control-alt-d. If you want to learn about how to minimize a qt window from within your code(what I think you probably want), I recommend you check out the surprisingly clear documentation at doc.qt.io.

Constraining other application's window sizes through Qt Application

I'm looking for a way in Qt to constrain other application window's (some will not be Qt) so that when maximized don't overlap my Qt application. Essentially I want to create the Windows Taskbar. I'd like the applications edge to dock to the appropriate edge of my Qt Taskbar in the same way that applications dock to the Windows taskbar when they are maximized. I envision this taskbar to exist along the top edge of the screen, but would like to allow users to decide which edge it will live on.
I know it isn't hard to make a window that is always on top it's more the auto docking issue I'm having a hard time figuring out.
I'm right now only looking to accomplish this on Windows.
Thank for any help.
Detailed explanation on how to do it would be too long for an answer here, but MSDN documentation on SHAppBarMessage should get you started. Taskbar created like that can even be part of winows taskbar ;)

Needed: A popup window without a taskbar icon

I am designing a UI engine that needs to render into popup (WS_POPUP) windows. As these windows cannot be children of other windows, each instance is given its own taskbar icon.
I need a way to prevent the taskbar icons from appearing for certain windows that are created as "dialogs". I cannot use an OS-provided dialog because they all have frames (and I can't figure out how to render into them) or a tool-created custom dialog (which seem to require the CLR).
I am not an expert with the windows API and I feel that I have missed something obvious...
Also: Anything involving CLI/CLR is not an option.
EDIT:
The WS_EX_NOACTIVATE style can be used for this purpose as well, though the activation behavior would need to be emulated by the program.
If you set the WS_EX_TOOLWINDOW extended style for your window, it won't be shown in the task bar or Alt+Tab list. This does cause the window to be rendered slightly differently, however (thinking floating tool palette).

Qt Tray Icon Drag and Drop

Does anyone know if it is possible to use drag and drop with a tray icon using Qt?
I've been doing some research and here is what I have come up with:
A QSystemTrayIcon cannot explicitly handle a drag/drop event. However there is a workaround based on the Spifftastic tray icon location method.
You create a uniquely colored icon
and place it as the icon for a brief
moment and take a screenshot of it.
Given that you know the color
sequence for the icon, you can
search through the screenshot and
locate the particular icon's
location.
A transparent widget is positioned
over the icon and is used as the
drop target.
I have yet to work at a few of the finer details of the operation but that is the gist of it. All things considered it is a hacky way of things but given that there are no other ways to do this I think it is acceptable.
Fluffy App (written in C#) uses the Spifftastic method to locate the tray icon. I'm assuming the part about the transparent window is how they accomplish that but I have yet to decompile and examine their system.
Since QSystemTrayIcon is a QObject, not a QWidget, my guess is this is not possible. The system tray icon isn't really owned by Qt - it's passed on to the 'desktop', i.e whatever part of the Gnome/KDE/Windows/Mac is drawing the relevant area. At least on Mac, you'd be dropping on the menu-bar, which would be a very strange UI. For Gnome and KDE it's a FreeDesktop.org standard, but again I don't think its your process which actually does the drawing, and hence there's no way for Qt to get events such as drag and drop to you.

Creating a custom context menu Window (WinAPI)

I'm wondering how to create windows like these alt text http://img824.imageshack.us/img824/997/this.jpg
I'm refering to the one that says Marquee selection tool... these ones. I'm also not referring to the skin. I know how to do my own drawing and what not, this is not the issue. It's because windows usually need a parent which means it should not be possible for these windows to overlap into the tools. The only windows that can do this are context menus and menus. How can I create this style of window? Thanks
I think you are confusing the concept of owner windows and parent windows. Only dialog controls have parent windows, and these are automatically clipped by the parent's client area. Other windows have owner windows. This is a weaker relationship. There's nothing stopping a window from overlapping its owner.
Also, I wouldn't assume that just because the toolbar launches the context menu that the toolbar window has a relationship with the menu window. It might or might not, depending on how things are coded behind the scenes.
In any case, just try it out. Use the TrackPopupMenu() to create a popup. You can have it overlap the owner window without difficulty. Any window without the WS_CHILD style will exhibit the same behaviour.