Solved How to disable the close button of a QProgressDialog?
-
Thanks for the help.
Actually, I don't want to disable the cancel button.
I want to disable the 'native window close button' (the X option from the left upper corner). -
@KelvinSP it looks like your looking at "window flags". You may want to take a look at this example showing how the hints apply to a widget
-
@Pablo-J.-Rogina thanks a lot. "Window flags" are exactly what I'm looking for.
The problem here is that I'm using the
Qt::WindowCloseButtonHint
flag to 'block' the native close button of a QProgressDialog and it works well on Windows but it does not block the close button on OS X. I have tried other flags but none of them worked as expected. -
Qt has no control over how the window manager treats the window flags. The OSX window manager may simply ignore what you "hint" with the flags and add the close button anyway. From the docs:
Some of these flags depend on whether the underlying window manager supports them.
-
@kshegunov thanks, it makes sense. So, there is no window flag which can accomplish this task on OS X?
-
There are no window flags that are guaranteed to be respected. I don't work on OSX, so someone may correct me, but if it doesn't respect your hint I don't think you can do much about it.
-
dlg->setWindowFlags(Qt::WindowTitleHint); X button is blocked. try
-
@Taz742 it doesn't work as expected. I just want to keep the X (close) button disable/unavailable. Thanks.
-
I finally found a solution. It worked well with the following combination of flags:
progressDialog->setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
Thank you so much for all help.
-
Excellent! Please don't forget to mark your post as solved. Cheers