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. QProgressDialog: can't disable "close window" button on mac?
QtWS25 Last Chance

QProgressDialog: can't disable "close window" button on mac?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 910 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.
  • D Offline
    D Offline
    davecotter
    wrote on last edited by
    #1

    so i try to do this:

    qDlgP->setWindowFlags(qDlgP->windowFlags() & ~Qt::WindowCloseButtonHint);
    

    and on Windows the "X" in the upper right is grayed out (can't click it).

    when i try the same on mac, the red dot in the upper left is still available. it's NOT documented that i must choose that option on window creation, that it can't be changed after the fact, so ... ?

    but if it MUST be done at window creation, what are the DEFAULT flags i should pass in, minus WindowCloseButtonHint? i can't find that either.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      davecotter
      wrote on last edited by
      #3

      okay the special sauce for this one is you have to add in:

      Qt::CustomizeWindowHint
      

      i'm surprised, but okay.

      it's like, "here's this obvious api you can use. but you can't use it until you enable its use by using this other, obscure api"

      :D

      kshegunovK 1 Reply Last reply
      1
      • D Offline
        D Offline
        davecotter
        wrote on last edited by
        #2

        okay after some investigation these are the default window flags:

          Qt::Window 
        | Qt::WindowTitleHint
        | Qt::WindowSystemMenuHint
        | Qt::WindowContextHelpButtonHint 
        | Qt::WindowCloseButtonHint;
        

        just add Qt::Dialog for a dialog.

        but i also discovered that it does NOT matter if i pass the flags (minus WindowCloseButtonHint) when constructing the dialog, the close button is still there, and enabled, and it closes the dialog.

        am i missing something?

        1 Reply Last reply
        0
        • D Offline
          D Offline
          davecotter
          wrote on last edited by
          #3

          okay the special sauce for this one is you have to add in:

          Qt::CustomizeWindowHint
          

          i'm surprised, but okay.

          it's like, "here's this obvious api you can use. but you can't use it until you enable its use by using this other, obscure api"

          :D

          kshegunovK 1 Reply Last reply
          1
          • D davecotter

            okay the special sauce for this one is you have to add in:

            Qt::CustomizeWindowHint
            

            i'm surprised, but okay.

            it's like, "here's this obvious api you can use. but you can't use it until you enable its use by using this other, obscure api"

            :D

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #4

            Bear in mind this is platform specific (actually window manager specific). Qt passes the hints to the window manager, but the latter may choose to ignore them! So it isn't exactly portable to depend on the behaviour.

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply
            2
            • D Offline
              D Offline
              davecotter
              wrote on last edited by
              #5

              well, it works on mac and windows, which is what i care about

              kshegunovK 1 Reply Last reply
              0
              • D davecotter

                well, it works on mac and windows, which is what i care about

                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by
                #6

                @davecotter said in QProgressDialog: can't disable "close window" button on mac?:

                well, it works on mac and windows, which is what i care about

                Fair enough. I'm just saying it may stop working for some future version of mac or windows. Also as a note, this doesn't disable the system menu (the one you get by right-clicking on the application icon) on windows, at least last time I checked. It's completely controlled by the OS and can't be removed, keep that in mind.

                Read and abide by the Qt Code of Conduct

                1 Reply Last reply
                1

                • Login

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