View Full Version : Remove max,min button on a QMainWindow

16th July 2007, 12:27
I have developed an application o Windows.While porting the application to Linux i encountered some problems.I had removed the max,min buttons on the QmainWindow by passing an argument Qt::WindowSystemMenuHint to the constructor.It worked fine on Windows OS but on porting to Linux minimize button on QMainWindow is visible.I even tried using setWindowFlags() but did not work...Anybody suggest some approach to solve the problem

16th July 2007, 12:41
this following code working for me on window.this code removing all max, min and close button from window title.
first line of code making framless window then 2nd line adding only titlebar without button. I hope this will work for you

setWindowTitle(tr("your title"));

16th July 2007, 12:48
I tried with ur code...I am still getting the minimize buttton....I am not able remove the minimize button.....Any idea of window manager for Linux

16th July 2007, 13:00
now you getting only minmize button or all buttons?
try this, first you make flag 0 then you add only Qt::WindowTitleHint.

Qt::WindowFlags flags = 0;
flags |= Qt::FramelessWindowHint;// i think this not required
flags |= Qt::WindowTitleHint;

16th July 2007, 13:29
I think by default minimize and close button on the window are visible. I tried testing setWindowFlags(Qt::WindowMaximizeButtonHint),even maximize button is also not visible.

26th November 2007, 22:55

I tray and retray the code for remove max botton on a QDialog window but it not work....
I use Qt4 on a kde desktop. I try this for remove a help button and it work fine:

Qt::WindowFlags flags = roboteditvar->windowFlags();
roboteditvar->setWindowFlags(flags & ~Qt::WindowContextHelpButtonHint);

I have check the windowflags example on my computer, but also this not work for disable the WindowMaximizeButtonHint.


18th April 2011, 15:03
setWindowFlags( Qt::Window
| Qt::WindowTitleHint
| Qt::CustomizeWindowHint );

18th May 2011, 12:22
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.

3rd August 2012, 14:27
I hope you want ready made code so please go thru below code.

m_MainWindow->setWindowState( m_MainWindow->windowState() & (~Qt::WindowMinimized | Qt::WindowActiver));
Qt::WindowFlags windowFlags = (Qt::Dialog | Qt::CustomizeWindowHint);

if(bShowCloseOnly) //Show only close button
windowFlags |= Qt::WindowCloseButtonHint;
else //show only close and minimize button
windowFlags |= Qt::WindowMinimizeButtonHint;
windowFlags |= Qt::WindowCloseButtonHint;
m_MainWindow->setWindowFlags( windowFlags );


3rd August 2012, 14:36
Have you noticed that last post in this thread has been posted at 18th May 2011, 13:22 (more than one year ago)? :)