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
Forum Updated to NodeBB v4.3 + New Features

Disable the close button of a QMessageBox

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 8.2k 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.
  • ZoptuneZ Offline
    ZoptuneZ Offline
    Zoptune
    wrote on 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 :)

    dobedidooD 1 Reply Last reply
    0
    • ZoptuneZ Zoptune

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

      dobedidooD Offline
      dobedidooD Offline
      dobedidoo
      wrote on 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?

      ZoptuneZ 1 Reply Last reply
      4
      • dobedidooD dobedidoo

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

        ZoptuneZ Offline
        ZoptuneZ Offline
        Zoptune
        wrote on last edited by
        #3

        @dobedidoo

        Thank you very much !

        Worked exactly as i wanted :)

        1 Reply Last reply
        0

        • Login

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