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. Strange: QProgressDialog keeps appearing when clicking on menus on the main window
Qt 6.11 is out! See what's new in the release blog

Strange: QProgressDialog keeps appearing when clicking on menus on the main window

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 3 Posters 2.1k Views 2 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.
  • GuerrianG Offline
    GuerrianG Offline
    Guerrian
    wrote on last edited by Guerrian
    #1

    I have a QProgressDialog declared in the MainWindow class. It is setup in the MainWindow constructor as follows:

        dialog = new QProgressDialog(tr("Processing") + "...", tr("Cancel"), 0, 4, this);
        dialog->setWindowModality(Qt::WindowModal);
    

    It is strange but when I click on menu (headings) on the main window, the dialogue appears all by it self without any code calling it or without clicking on any menu item.

    Linux Mint 18.3
    Qt 5.14.1
    Qt Creator 4.11.1

    raven-worxR 1 Reply Last reply
    0
    • GuerrianG Guerrian

      I have a QProgressDialog declared in the MainWindow class. It is setup in the MainWindow constructor as follows:

          dialog = new QProgressDialog(tr("Processing") + "...", tr("Cancel"), 0, 4, this);
          dialog->setWindowModality(Qt::WindowModal);
      

      It is strange but when I click on menu (headings) on the main window, the dialogue appears all by it self without any code calling it or without clicking on any menu item.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Guerrian
      then there must be more code which causing this behavior ;)

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by mrjj
        #3

        Hi
        Actually i could reproduce it
        with only that 2 lines of code
        alt text

        I simply run program and wait a moment. ( 5-8 secs) then it pops :)
        (also in a new clean default GUI project with no menus )

        1 Reply Last reply
        2
        • GuerrianG Offline
          GuerrianG Offline
          Guerrian
          wrote on last edited by Guerrian
          #4

          I need this to be in the scope of the main window. How do I control this dialogue and prevent it from appearing randomly?

          Update
          I tried adding "reset", seems to have solved the problem:

          dialog = new QProgressDialog(tr("Processing") + "...", tr("Cancel"), 0, 4, this);
          dialog->setWindowModality(Qt::WindowModal);
          dialog->reset();
          

          Linux Mint 18.3
          Qt 5.14.1
          Qt Creator 4.11.1

          1 Reply Last reply
          1
          • mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi
            try without
            dialog->setWindowModality(Qt::WindowModal);
            and see if that makes a difference.

            GuerrianG 1 Reply Last reply
            0
            • mrjjM mrjj

              Hi
              try without
              dialog->setWindowModality(Qt::WindowModal);
              and see if that makes a difference.

              GuerrianG Offline
              GuerrianG Offline
              Guerrian
              wrote on last edited by
              #6

              @mrjj
              But when I do want it to show, I want the window to be modal!

              Linux Mint 18.3
              Qt 5.14.1
              Qt Creator 4.11.1

              mrjjM 1 Reply Last reply
              0
              • GuerrianG Guerrian

                @mrjj
                But when I do want it to show, I want the window to be modal!

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #7

                @Guerrian
                Yeah, u can set same place you call show()
                It was just for test. Its a bit odd it pops up.

                Never mind. :)
                Reading the docs , it clear states why it pops.
                its due to setMinimumDuration
                http://doc.qt.io/qt-5/qprogressdialog.html#minimumDuration-prop

                GuerrianG 1 Reply Last reply
                2
                • mrjjM mrjj

                  @Guerrian
                  Yeah, u can set same place you call show()
                  It was just for test. Its a bit odd it pops up.

                  Never mind. :)
                  Reading the docs , it clear states why it pops.
                  its due to setMinimumDuration
                  http://doc.qt.io/qt-5/qprogressdialog.html#minimumDuration-prop

                  GuerrianG Offline
                  GuerrianG Offline
                  Guerrian
                  wrote on last edited by Guerrian
                  #8

                  @mrjj
                  Without this line it still pops up:

                  dialog->setWindowModality(Qt::WindowModal);
                  

                  I found that it does not pop up if I use reset at the start:

                  dialog->setWindowModality(Qt::WindowModal);
                  dialog->reset();
                  

                  ...use this if the process is cancelled:

                  dialog->close();
                  

                  ...and do nothing if the process finishes ie. the progress bar reaches maximum, because it auto resets in that case.

                  Linux Mint 18.3
                  Qt 5.14.1
                  Qt Creator 4.11.1

                  mrjjM 1 Reply Last reply
                  0
                  • GuerrianG Guerrian

                    @mrjj
                    Without this line it still pops up:

                    dialog->setWindowModality(Qt::WindowModal);
                    

                    I found that it does not pop up if I use reset at the start:

                    dialog->setWindowModality(Qt::WindowModal);
                    dialog->reset();
                    

                    ...use this if the process is cancelled:

                    dialog->close();
                    

                    ...and do nothing if the process finishes ie. the progress bar reaches maximum, because it auto resets in that case.

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by mrjj
                    #9

                    @Guerrian
                    Yes ?
                    I posted why :)
                    the docs have the info.

                    GuerrianG 1 Reply Last reply
                    1
                    • mrjjM mrjj

                      @Guerrian
                      Yes ?
                      I posted why :)
                      the docs have the info.

                      GuerrianG Offline
                      GuerrianG Offline
                      Guerrian
                      wrote on last edited by
                      #10

                      @mrjj
                      OK, but does it explain about reset? It says about showing "any progress", this seems to apply when there is zero progress. Whereas reset can actually hide the dialogue.

                      Linux Mint 18.3
                      Qt 5.14.1
                      Qt Creator 4.11.1

                      mrjjM 1 Reply Last reply
                      0
                      • GuerrianG Guerrian

                        @mrjj
                        OK, but does it explain about reset? It says about showing "any progress", this seems to apply when there is zero progress. Whereas reset can actually hide the dialogue.

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        @Guerrian
                        Yes it says that
                        void QProgressDialog::reset()
                        Resets the progress dialog. The progress dialog becomes hidden if autoClose() is true.

                        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