Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Disable the close button of a QMessageBox
QtWS25 Last Chance

Disable the close button of a QMessageBox

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 8.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    Zoptune
    wrote on 9 Jun 2016, 14:19 last edited by
    #1

    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 :)

    D 1 Reply Last reply 9 Jun 2016, 17:04
    0
    • Z Zoptune
      9 Jun 2016, 14:19

      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 :)

      D Offline
      D Offline
      dobedidoo
      wrote on 9 Jun 2016, 17:04 last edited by
      #2

      @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?

      Z 1 Reply Last reply 10 Jun 2016, 13:29
      4
      • D dobedidoo
        9 Jun 2016, 17:04

        @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?

        Z Offline
        Z Offline
        Zoptune
        wrote on 10 Jun 2016, 13:29 last edited by
        #3

        @dobedidoo

        Thank you very much !

        Worked exactly as i wanted :)

        1 Reply Last reply
        0

        2/3

        9 Jun 2016, 17:04

        • Login

        • Login or register to search.
        2 out of 3
        • First post
          2/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved