View Full Version : How to hide Close Button "X" on Widget ?
merry
23rd April 2008, 05: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, 07:47
Try this
setWindowFlags(Qt::WindowTitleHint);
or
setWindowFlags(Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint);
Hope it helps
nhs_0702
3rd May 2010, 09: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, 10:06
Disable or hide ??
Disable, I guess it will be difficult.
MorrisLiang
3rd May 2010, 11: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, 13: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, 14: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, 18: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
MhmRhm
25th January 2020, 08:03
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:
private:
void closeEvent(QCloseEvent *event) override;
and this to cpp file:
void MainWindow::closeEvent(QCloseEvent *event)
{
cout << "Here in close" << endl;
event->ignore();
}
More info? https://doc.qt.io/qt-5/qwidget.html#closeEvent
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.