Hello,
How can I enable and disable the Close (X) button on Qt window
Hello,
How can I enable and disable the Close (X) button on Qt window
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.
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.
Bookmarks