Qt without a window icon (system menu)

Is there a way to create a window (e.g. QDialog) without the window icon in the upper left corner? I tried using a transparent icon, but it leaves a blank space.

Edit: The richardwb solution below removes the system menu, but also removes Minimize / Maximize / Close (header buttons). This can be done at the moment, but I hope there is a solution that saves the signature buttons.

+5
source share
1 answer

If you don’t need buttons at all with an inscription, you can achieve this by setting a few flag hints :

setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint);

Qt Demo , (Qt Demo- > Widgets- > Flags Window), , .


, "//", , Qt . , Qt, , Windows Close, .

Windows, ():

#if defined(Q_WS_WIN)
    // don't forget to #include <windows.h>
    HWND hwnd = winId();
    LONG_PTR style = GetWindowLongPtr(hwnd, GWL_STYLE);
    style &= ~WS_SYSMENU; // unset the system menu flag
    SetWindowLongPtr(hwnd, GWL_STYLE, style);
    // force Windows to refresh some cached window styles
    SetWindowPos(hwnd, 0, 0, 0, 0, 0, 
        SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
#endif

: swongu, . "/", , .

+10
source

All Articles