PDA

View Full Version : Mac titlebar buttons Issue.



kaushal_gaurav
29th August 2008, 09:49
Hi,
I need to create a window on MAC with just a Close button enabled and minimize and maximize buttons disabled.
but what i am getting is a window with maximize button enabled and close and minimize button diabled.

I have tried some variations with setWindowFlags() but of no avail.

Please help....!

GK

kaushal_gaurav
29th August 2008, 19:29
Isn't there a way?

aamer4yu
30th August 2008, 10:20
I tried in the Windows Flags example, and I could get a Close button without minimize or maximize button using -

Qt::Window | Qt::WindowSystemMenuHint

but in this u WONT HAVE min/ max buttons... i am not sure if u want them on the window yet disabled....

Hope this is what u want :)

kaushal_gaurav
2nd September 2008, 07:24
This does not work for me.
I want it on MAC. When i use setWindowFlags(Qt::Window | Qt::WindowSystemMenuHint);
only minimize button is disabled but not the maximized button. I have treid all combinatinos from WindowFlags example but Maximine button on MAC is not disabled...
Does anybody know a native MAC API to disable maximize button on title bar?

Help...

GK

kyue
9th July 2009, 19:36
This may be a little late, but you need to clear the default Windows Hint first. The following will enable the Close and Maximize button, and disable the Minimize button:


setWindowFlags(windowFlags() | Qt::CustomizeWindowHint);

Now...I too need to find a way to disable the Maximize button. Here are some of the methods I've tried and none of the them were successful for me...


Qt::WindowFlags flag = windowFlags() | Qt::CustomizeWindowHint;
//flag ^= Qt::WindowMaximizeButtonHint;
//flag &= ~Qt::WindowMinMaxButtonsHint;
//flag &= ~Qt::WindowMinimizeButtonHint;
//flag &= ~Qt::WindowMaximizeButtonHint;
//flag |= Qt::WindowSystemMenuHint;
setWindowFlags(flag);

kyue
9th July 2009, 21:45
Actually, I found a solution to disable the Maximize button thanks to sir_johann in this post:

http://www.qtcentre.org/forum/f-qt-programming-2/t-disabling-the-maximize-button-in-qmainwindow--3563.html

I was using Qt Designer and it did not behave as I expected it to. It was much easier and more reliable to set this attributes programmatically. Therefore, to disable the "Maximize" button on Mac, you need to clear the Maxmize flag and set a fixed size for the widget:


Qt::WindowFlags flag = windowFlags() | Qt::CustomizeWindowHint;
flag ^= Qt::WindowMaximizeButtonHint;
setWindowFlags(flag);
setFixedSize(200, 200);

and the Maximize button will become disabled.