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 insert a progress bar before a dialog is displayed?

How to insert a progress bar before a dialog is displayed?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 1.7k 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.
  • Qt_crazyerQ Offline
    Qt_crazyerQ Offline
    Qt_crazyer
    wrote on last edited by
    #1

    I was troubled by the progress bar recently.
    Because one of my dialog has a long opening time, I want to insert a progress bar during the waiting period to show the progress of the dialog opening.
    How should I do it? Thanks for all advice!

    m_SerialPortDialog->show();
    
    m_ProgressBar->show();
    m_ProgressBar->setRange(0,100);
    for(int i=1;i<=100;i++)
          m_ProgressBar->setValue(i);
    
    jsulmJ 1 Reply Last reply
    0
    • Pradeep KumarP Offline
      Pradeep KumarP Offline
      Pradeep Kumar
      wrote on last edited by
      #2

      Hi,

      Add the progressbar to the widget , make the widget background transparent, before showing up dialog.
      Show the progressbar before the dialog is shown.
      Once the dialog is shown, hide the progressbar.

      Thanks,

      Pradeep Kumar
      Qt,QML Developer

      1 Reply Last reply
      0
      • Qt_crazyerQ Qt_crazyer

        I was troubled by the progress bar recently.
        Because one of my dialog has a long opening time, I want to insert a progress bar during the waiting period to show the progress of the dialog opening.
        How should I do it? Thanks for all advice!

        m_SerialPortDialog->show();
        
        m_ProgressBar->show();
        m_ProgressBar->setRange(0,100);
        for(int i=1;i<=100;i++)
              m_ProgressBar->setValue(i);
        
        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @Qt_crazyer From design/usability point of view it would be better if the dialog itself would handle this. It should show a progress bar as long as it is busy and then the normal content.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        2
        • Pradeep KumarP Offline
          Pradeep KumarP Offline
          Pradeep Kumar
          wrote on last edited by
          #4

          @jsulm ,

          meaning using only one dialog to both the contents, progressbar and actual information, using progressbar make it indicating till actual information needs to be displayed in the same dialog.

          Thanks,

          Pradeep Kumar
          Qt,QML Developer

          1 Reply Last reply
          0
          • Pradeep KumarP Offline
            Pradeep KumarP Offline
            Pradeep Kumar
            wrote on last edited by Pradeep Kumar
            #5

            Hi,

            @Qt_crazyer ,

            Inherit from QDialog, ur own class, add progressbar , then update the progressbar untill u get the value or the corresponding information in dialog, then make progressbar visible false.

            Before getting the value :

            0_1516023374786_progressbar.PNG

            After getting the value :

            0_1516023408783_progressbarValue.PNG

            the output is sample one, u can replace with the info (value 21) which u required.
            the window dialog(progressbar) opens on click of button, here it is just a sample program.

            Thanks,

            Pradeep Kumar
            Qt,QML Developer

            Qt_crazyerQ 1 Reply Last reply
            3
            • Pablo J. RoginaP Offline
              Pablo J. RoginaP Offline
              Pablo J. Rogina
              wrote on last edited by
              #6

              @Qt_crazyer just in case there's a QProgressDialog class that you can even combine with QFutureWatcher class to monitor the progress of a long-running operationlike this example does.

              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
              2
              • Pradeep KumarP Pradeep Kumar

                Hi,

                @Qt_crazyer ,

                Inherit from QDialog, ur own class, add progressbar , then update the progressbar untill u get the value or the corresponding information in dialog, then make progressbar visible false.

                Before getting the value :

                0_1516023374786_progressbar.PNG

                After getting the value :

                0_1516023408783_progressbarValue.PNG

                the output is sample one, u can replace with the info (value 21) which u required.
                the window dialog(progressbar) opens on click of button, here it is just a sample program.

                Thanks,

                Qt_crazyerQ Offline
                Qt_crazyerQ Offline
                Qt_crazyer
                wrote on last edited by
                #7

                @Pradeep-Kumar
                It's really a good way to do it. Thank you.

                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