PDA

View Full Version : How to hide Close Button "X" on Widget ?



merry
23rd April 2008, 06:25
Hi all

Working on Qt4.3.4 on Windows XP, I want to know how to hide Close (X) that is appearing on right hand side of the widget.


Earlier i had working on MAC OS, there i set WindowModality to Qt::ApplicationModal , then close button hides,

Is there any flag for windows to hide the close button.


Regards

Merry

aamer4yu
23rd April 2008, 08:47
Try this
setWindowFlags(Qt::WindowTitleHint);
or
setWindowFlags(Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint);

Hope it helps

nhs_0702
3rd May 2010, 10:54
Try this
setWindowFlags(Qt::WindowTitleHint);
or
setWindowFlags(Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint);

Hope it helps


http://c.upanh.com/upload/5/1022/3L0.10179802_1_1.png

i want disable close button,how do that do ?

aamer4yu
3rd May 2010, 11:06
Disable or hide ??

Disable, I guess it will be difficult.

MorrisLiang
3rd May 2010, 12:07
If you cannot find a way to disable or hide it.Perhaps this way would help:
1.remove the window frame by using setWindowFlags()
2.draw the window frame yourself.

But you have a bunch of work to do,if you choose this way.

MorrisLiang
3rd May 2010, 14:32
Ok,I find the flag.
See the screenshot below:
http://i960.photobucket.com/albums/ae82/liangmorr/QQE688AAE59BBEE69CAAE591BDE5908D.png
use Qt::CustomizeWindowHint,you will get no X button,but also no title....

squidge
3rd May 2010, 15:10
Try http://www.qtcentre.org/threads/24549-How-to-Disabel-close-button-on-top-corner-of-widget?p=142112#post142112

or alternatively, you could draw the title bar yourself.

arnaizf
3rd May 2010, 19:04
I did it a few minutes ago for my application. In main.cpp, write:



widget.setWindowFlags ( Qt::CustomizeWindowHint | Qt::WindowTitleHint);
widget.show();


Now you do not have close button, neither a menu close and ALT-F4 won't work.
Hope this can be helpful.

I'm using Qt4 under Linux