First I have a QMessageBox and I would like hide the red cross (close). I tried with the WindowFlags but I didn't manage.
Secondly, this QMessageBox can't be closed by the user but it can be closed by the code. And when it is closing I wouldn't like it execute the code on the answer No (or Yes).
Don't you need to turn off the WindowCloseButtonHint? So something like
If you can get away with using the standard functionality with something like this then it's less code to go wrong and less to maintain for you.