Disable the close button of a QMessageBox



  • Hi,

    How can i disable or remove the close button of a QMessageBox ?
    I need the user to click the only button in the messagebox.

    I have tried this :
    msgBox.setWindowFlags(msgBox.windowFlags() & ~Qt::WindowCloseButtonHint)

    but it's not working

    thx for help :)



  • @Zoptune:

    I tried this and it seems to work for me (I'm using Windows):

    msgBox.setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);

    The Qt::CustomizeWindowHint flag turns off the default window title hints (in my case, I had only the close button by default), but it also removed the title bar, which is why I needed the second flag (Qt::WindowTitleHint).

    Works for you as well?



  • @dobedidoo

    Thank you very much !

    Worked exactly as i wanted :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.