I hav created a Dialog ...I want to disable the close button on the dialog...
Printable View
I hav created a Dialog ...I want to disable the close button on the dialog...
Hello,
You have to use setWindowFlags() method, and I think you'll have to omit this particular flag :
Qt::WindowSystemMenuHint
I have used designer to create the dialog. i hav used setContextMenuPolicy(Qt::NoContextMenu) to disable the maximize,minimize and close buttons.The ui file works fine for Windows OS but on Linux i am getting the close button on the dialog..Is there any option in the designer to remove the close button
use m_pCloseBtn->setEnabled(false);
Its not the qPushButton the clse,maximize,minimize button the Dialog
you write following code, this will not disable but don't close your application.
I have used designer to create the dialog. i hav used setContextMenuPolicy(Qt::NoContextMenu) to make the maximize,minimize and close buttons invisble.The ui file works fine for Windows OS but on Linux the close button on the dialog is visible ..Is there any option in the designer to remove the close button...Sorry for using the term disable its actually visiblity.....
this following code working for me on window.this code removing "X"button from title. I dont know it work on unix or not.
Code:
setWindowFlags(Qt::FramelessWindowHint); setWindowFlags(Qt::WindowTitleHint); setWindowTitle(tr("Virtual Development Board"));
U r code works fine. But i do not get the title bar.Is there any way to hav the title bar with close button only..The maximize and minimize buttons on the MainWindow should be invisible....
see the example code Window Flags Example: from
http://doc.trolltech.com/4.3/widgets-windowflags.html
this example code working fine on windows. you test this on linux, in this example depend on different check box it showing minimize , maximize and close button, and none of these also.
see void ControllerWindow::updatePreview() in example.
I tested the code given in the website..It has solved my problem.I hav another one.I need a Dialog that has no close button on the dialog but has a titlebar...I tried using FramelessWindowHint but titlebar is not visible...Suggest some approach where i can hav a titlebar with no close button.
after FramelessWindowHint ,use WindowTitleHint then only titlebar will be visible
Code:
setWindowFlags(Qt::FramelessWindowHint); setWindowFlags(Qt::WindowTitleHint);
I tried with the code given by you.It gives a frameless window with no titlebar and the I tried with option setWindowFlags(Qt::Tool|Qt::FramelessWindowHint|Qt ::WindowTitleHint).Still i am not able to get the title bar with no close,max,min button.