PDA

View Full Version : How to hide close button in QDialog?



grantbj74
26th September 2011, 07:43
Hi,

Just wondering how to hide the close button on a QDialog?

Thanks
Brendan

wysota
26th September 2011, 08:51
By modifying flags set on the widget. Just be aware this will only hide the button, it won't prevent your dialog from being closable.

grantbj74
27th September 2011, 00:55
Thanks.

I looked at the Window Flags Example in Qt Assistant. Unfortunately Qt::SubWindow wasn't included and this was the only flag that hid the close button.

This is what worked in the end, I put it in the dialog constructor.



this->setWindowFlags(Qt::SubWindow);

wysota
27th September 2011, 01:08
No, that's not a good approach. You need to use Qt::CustomizeWindowHint and remove Qt::WindowCloseButtonHint from the hints passed to the window.