How to hide windows close/minimize/maximize button on titlebar?
How to hide windows close/minimize/maximize button on titlebar and keep all others no change?
Which platform are you talking about? Windows, Mac, Linux?
Look at setWindowsFlags() method.
"The CustomizeWindowHint flag is used to enable customization of the window controls. This flag must be set to allow the WindowTitleHint, WindowSystemMenuHint, WindowMinimizeButtonHint, WindowMaximizeButtonHint and WindowCloseButtonHint flags to be changed."
there is a good example in Qt Demo.
examples > widgets > Window flags
You can experiment using different settings.
I am working on Windows. I checked the "Window flags" example before and it would fit my application.
If I set:
@setWindowFlags(Qt::WindowTitleHint | Qt::CustomizeWindowHint);@
I can get rid of 3 buttons. But the icon also gone(I need the icon). If I do not set as above, the 3 buttons always there.
@setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);@
you have to add the Qt::WindowSystemMenuHint for the icon. But take care, it might also add the close button (see docs).
EDIT: Hiding the buittons from the title bar will not disable the functions from the system menu....
using Qt::WindowSystemMenuHint will not hide close button. But at least it disable the close button. I might use it. But I wish only icon, title on title bar. Nothing else.
I think this is a limitation by the Windows window system. You will experience the same problems in native Windows code, eg. C#.
What you can do without fail is using a frameless window (Qt::FramelessWindowHint) and draw your own icon and title.
try setting the form's minimum size equal to the form's maximum size. it worked for me. except for the close button.... I use the QcloseEvent() to handle that...