Is there any way in QML to add a button to the main window menu (where the minimize-close-move buttons is the window itself next to them)

UPD: Any solutions for drawing a new panel will also work. The main condition: the resulting panel should look like the main window pane. That is, when changing the theme, windows should take on the appearance of this theme (including transparent one)

    1 answer 1

    Removing standard buttons is much easier than adding them (see example ). But with the addition of its new elements is not easy.

    Immediately note that the application is done only under Windows (judging by the text of the question). I don’t know anything special in Qt to support these buttons, so I’ll have to dive into the WIN API. Before the Aero epoch, the problem was solved easily - we could draw anything on our own: just catch WM_NCPAINT ( redrawing outside the client area ), respond to window header events ( WM_NCHITTEST , WM_NCLBUTTONDOWN , etc.).

    This is about processing WM_PAINT , just draw not inside the window, but in the whole window.

    But since the beginning of the era of visual schemes, everything has become much more complicated. As far as I understand, the only normal way is to repeat the styles of drawing buttons with our pens. That is, in your code you need to see which version of Windows the user has and whether Aero is enabled to choose which frame width to use, etc. The approach is bad (I will be glad if someone specifies a more human solution), so it is better to think soberly whether it is necessary to add new buttons.

    But since no one wants to do this, they usually just ignore the Windows styles (for example, Google Chrome uses its own window style completely, so it boldly shoves what buttons it wants in any part of the window title).

    • Thank you so much for such a detailed response! - Mira
    • And what do you think about this should be fun? msdn.microsoft.com/en-us/library/windows/desktop/… - Mira
    • Yes, you can draw the title of the window (well, in general, the whole frame). But the problem is the same: the style of the button will have to be invented independently (or try to repeat the style of the current version of the operating system). - Ilya
    • I will add after attempts to apply "expand the frame to the client area" - this only works for aero. If Aero is disabled - the frame remains in place - Mira
    • Strange. Create one more question with your code - let's see. - Ilya