c++qtpyqt5

How to prevent closing QMessageBox after clicking a button


I have 3 buttons on QMessageBox added by QMessageBox::addButton() method. Is it possible to prevent closing the message box if a button has been clicked? By default every button closes the window, but I don't want to do it for one button.


Solution

  • I looked through the addButton() functions overloads, but there is no custom behavior for the buttons you add with this method. They will behave like the standard buttons on a messagebox should.

    However if you want to create a fully customizable dialog, then your best option is to extend the QDialog class and use whatever controlls you like on it.