How to hide Close Button "X" on Widget ?
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
Re: How to hide Close Button "X" on Widget ?
Try this
setWindowFlags(Qt::WindowTitleHint);
or
setWindowFlags(Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint);
Hope it helps
Re: How to hide Close Button "X" on Widget ?
Quote:
Originally Posted by
aamer4yu
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 ?
Re: How to hide Close Button "X" on Widget ?
Disable or hide ??
Disable, I guess it will be difficult.
Re: How to hide Close Button "X" on Widget ?
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.
Re: How to hide Close Button "X" on Widget ?
Ok,I find the flag.
See the screenshot below:
http://i960.photobucket.com/albums/a...91BDE5908D.png
use Qt::CustomizeWindowHint,you will get no X button,but also no title....
Re: How to hide Close Button "X" on Widget ?
Try http://www.qtcentre.org/threads/2454...112#post142112
or alternatively, you could draw the title bar yourself.
Re: How to hide Close Button "X" on Widget ?
I did it a few minutes ago for my application. In main.cpp, write:
Quote:
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
Re: How to hide Close Button "X" on Widget ?
Quote:
Originally Posted by
arnaizf
I did it a few minutes ago for my application. In main.cpp, write:
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
I believe another way around would be hijacking close event, add this ti header file:
and this to cpp file:
Code:
{
cout << "Here in close" << endl;
event->ignore();
}
More info? https://doc.qt.io/qt-5/qwidget.html#closeEvent