PDA

View Full Version : Enable and Disable Close (X)



anh5kor
24th March 2015, 07:05
Hello,

How can I enable and disable the Close (X) button on Qt window

Radek
24th March 2015, 07:36
By reimplementing closeEvent() method. You can ignore() (disable the 'X') or accept() (enable the 'X') the event. Note that this affects all kinds of closing the window, not only 'X'. Also, see delete on close flag and decide, whether you want only to hide the window or whether the window should be destroyed. See the QWidget::closeEvent description in the manual.

jefftee
25th March 2015, 06:45
How can I enable and disable the Close (X) button on Qt window
Look at QWindow::setFlags(). I believe there are some platform restrictions in play, but you can try removing the close button by using a custom window hint (Qt::CustomizeWindowHint) and removing the close button by ensuring Qt::WindowCloseButtonHint is removed from the window flags.

Read the full docs for QWindow::setFlags() to see the platform dependencies, etc.

Hope that helps.