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. How to disable the close button of a QProgressDialog?
Forum Updated to NodeBB v4.3 + New Features

How to disable the close button of a QProgressDialog?

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 5 Posters 6.2k Views 3 Watching
  • 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.
  • C Charlie_Hdz

    @KelvinSP

    Create a custom push button

    Disable that button with setDisable()

    set the Cancel push button by void QProgressDialog::setCancelButton(QPushButton * cancelButton)

    Enable it when you want.

    Kind Regards,

    Enrique

    K Offline
    K Offline
    KelvinSP
    wrote on last edited by KelvinSP
    #3

    @Charlie_Hdz

    Thanks for the help.
    Actually, I don't want to disable the cancel button.
    I want to disable the 'native window close button' (the X option from the left upper corner).

    1 Reply Last reply
    0
    • Pablo J. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on last edited by
      #4

      @KelvinSP it looks like your looking at "window flags". You may want to take a look at this example showing how the hints apply to a widget

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      K 1 Reply Last reply
      2
      • Pablo J. RoginaP Pablo J. Rogina

        @KelvinSP it looks like your looking at "window flags". You may want to take a look at this example showing how the hints apply to a widget

        K Offline
        K Offline
        KelvinSP
        wrote on last edited by
        #5

        @Pablo-J.-Rogina thanks a lot. "Window flags" are exactly what I'm looking for.

        The problem here is that I'm using the Qt::WindowCloseButtonHint flag to 'block' the native close button of a QProgressDialog and it works well on Windows but it does not block the close button on OS X. I have tried other flags but none of them worked as expected.

        kshegunovK 1 Reply Last reply
        0
        • K KelvinSP

          @Pablo-J.-Rogina thanks a lot. "Window flags" are exactly what I'm looking for.

          The problem here is that I'm using the Qt::WindowCloseButtonHint flag to 'block' the native close button of a QProgressDialog and it works well on Windows but it does not block the close button on OS X. I have tried other flags but none of them worked as expected.

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

          Qt has no control over how the window manager treats the window flags. The OSX window manager may simply ignore what you "hint" with the flags and add the close button anyway. From the docs:

          Some of these flags depend on whether the underlying window manager supports them.

          Read and abide by the Qt Code of Conduct

          K 1 Reply Last reply
          2
          • kshegunovK kshegunov

            Qt has no control over how the window manager treats the window flags. The OSX window manager may simply ignore what you "hint" with the flags and add the close button anyway. From the docs:

            Some of these flags depend on whether the underlying window manager supports them.

            K Offline
            K Offline
            KelvinSP
            wrote on last edited by
            #7

            @kshegunov thanks, it makes sense. So, there is no window flag which can accomplish this task on OS X?

            kshegunovK 1 Reply Last reply
            0
            • K KelvinSP

              @kshegunov thanks, it makes sense. So, there is no window flag which can accomplish this task on OS X?

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

              There are no window flags that are guaranteed to be respected. I don't work on OSX, so someone may correct me, but if it doesn't respect your hint I don't think you can do much about it.

              Read and abide by the Qt Code of Conduct

              Taz742T 1 Reply Last reply
              1
              • kshegunovK kshegunov

                There are no window flags that are guaranteed to be respected. I don't work on OSX, so someone may correct me, but if it doesn't respect your hint I don't think you can do much about it.

                Taz742T Offline
                Taz742T Offline
                Taz742
                wrote on last edited by Taz742
                #9

                dlg->setWindowFlags(Qt::WindowTitleHint); X button is blocked. try

                Do what you want.

                K 1 Reply Last reply
                0
                • Taz742T Taz742

                  dlg->setWindowFlags(Qt::WindowTitleHint); X button is blocked. try

                  K Offline
                  K Offline
                  KelvinSP
                  wrote on last edited by KelvinSP
                  #10

                  @Taz742 it doesn't work as expected. I just want to keep the X (close) button disable/unavailable. Thanks.

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    KelvinSP
                    wrote on last edited by KelvinSP
                    #11

                    I finally found a solution. It worked well with the following combination of flags:

                    progressDialog->setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
                    

                    Thank you so much for all help.

                    1 Reply Last reply
                    4
                    • Pablo J. RoginaP Offline
                      Pablo J. RoginaP Offline
                      Pablo J. Rogina
                      wrote on last edited by
                      #12

                      Excellent! Please don't forget to mark your post as solved. Cheers

                      Upvote the answer(s) that helped you solve the issue
                      Use "Topic Tools" button to mark your post as Solved
                      Add screenshots via postimage.org
                      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                      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