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: how to modal window

QProgressDialog: how to modal window

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 5 Posters 931 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.
  • sitesvS Offline
    sitesvS Offline
    sitesv
    wrote on last edited by sitesv
    #1

    Hi
    How to make QProgressDialog modal?
    In spite of setting parent and setting Qt::WIndowModal, it is not blocking parent window.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Give it a proper parent.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      sitesvS 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        Give it a proper parent.

        sitesvS Offline
        sitesvS Offline
        sitesv
        wrote on last edited by sitesv
        #3

        @Christian-Ehrlicher

        I found a difference in setting parent style

        1

        void MDIChild::show_p(){
        progress = new QProgressDialog("text","Cancel",0,100, this);
        progress->setWindowModality(Qt::WIndowModal);
        ...
        progress->show();
        }
        

        2

        void MDIChild::show_p(){
        progress = new QProgressDialog("text","Cancel");
        progress->setParent(this);
        progress->setWindowModality(Qt::WIndowModal);
        ...
        progress->show();
        }
        

        Modality works fine for first "set parent" variant only. And, I don't know why, but blocks all application, not a parent (mdi child) window only.

        Cobra91151C 1 Reply Last reply
        0
        • sitesvS sitesv

          @Christian-Ehrlicher

          I found a difference in setting parent style

          1

          void MDIChild::show_p(){
          progress = new QProgressDialog("text","Cancel",0,100, this);
          progress->setWindowModality(Qt::WIndowModal);
          ...
          progress->show();
          }
          

          2

          void MDIChild::show_p(){
          progress = new QProgressDialog("text","Cancel");
          progress->setParent(this);
          progress->setWindowModality(Qt::WIndowModal);
          ...
          progress->show();
          }
          

          Modality works fine for first "set parent" variant only. And, I don't know why, but blocks all application, not a parent (mdi child) window only.

          Cobra91151C Offline
          Cobra91151C Offline
          Cobra91151
          wrote on last edited by Cobra91151
          #4

          @sitesv

          Hello!

          You can try to set setWindowModality(Qt::ApplicationModal); to QProgressDialog object instead of Qt::WindowModal to check if it works for you in such case.
          Also, I would suggest to call QProgressDialog - exec() method instead of show().

          sitesvS 1 Reply Last reply
          0
          • Cobra91151C Cobra91151

            @sitesv

            Hello!

            You can try to set setWindowModality(Qt::ApplicationModal); to QProgressDialog object instead of Qt::WindowModal to check if it works for you in such case.
            Also, I would suggest to call QProgressDialog - exec() method instead of show().

            sitesvS Offline
            sitesvS Offline
            sitesv
            wrote on last edited by
            #5

            @Cobra91151 the same result. QProgressDialog blocks all app.

            Cobra91151C 1 Reply Last reply
            0
            • sitesvS sitesv

              @Cobra91151 the same result. QProgressDialog blocks all app.

              Cobra91151C Offline
              Cobra91151C Offline
              Cobra91151
              wrote on last edited by
              #6

              @sitesv

              Do you have the same issue with a simple QDialog or just a QProgressDialog? I ask because I had some issue with QProgressDialog button and to fix it I created my own progress dialog class which inherits from QDialog class.

              sitesvS 1 Reply Last reply
              0
              • Cobra91151C Cobra91151

                @sitesv

                Do you have the same issue with a simple QDialog or just a QProgressDialog? I ask because I had some issue with QProgressDialog button and to fix it I created my own progress dialog class which inherits from QDialog class.

                sitesvS Offline
                sitesvS Offline
                sitesv
                wrote on last edited by
                #7

                @Cobra91151 , thanks for an advice.
                Yes, this issue I have with QProgressDialog object only

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Hi,

                  There's one key information missing, what are you doing while the dialog is shown ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  sitesvS 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Hi,

                    There's one key information missing, what are you doing while the dialog is shown ?

                    sitesvS Offline
                    sitesvS Offline
                    sitesv
                    wrote on last edited by sitesv
                    #9

                    @SGaist said in QProgressDialog: how to modal window:

                    Hi,
                    There's one key information missing, what are you doing while the dialog is shown ?

                    Hi!
                    App waits for some process accomplish and user mustn't click anywhere on the app while qprocessdialog shows...

                    Same problem found with QMessageBox.
                    There is different behavior while centering in case of parent setting by constructor and by 'setParent'.

                    JoeCFDJ 1 Reply Last reply
                    0
                    • sitesvS sitesv

                      @SGaist said in QProgressDialog: how to modal window:

                      Hi,
                      There's one key information missing, what are you doing while the dialog is shown ?

                      Hi!
                      App waits for some process accomplish and user mustn't click anywhere on the app while qprocessdialog shows...

                      Same problem found with QMessageBox.
                      There is different behavior while centering in case of parent setting by constructor and by 'setParent'.

                      JoeCFDJ Offline
                      JoeCFDJ Offline
                      JoeCFD
                      wrote on last edited by JoeCFD
                      #10

                      @sitesv It could be a Qt bug. You can work around by disabling the parent widget or blocking all events handling inside the parent widget. I have to do this sometimes in my code for other reasons.

                      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