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. QProgressBar
Qt 6.11 is out! See what's new in the release blog

QProgressBar

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 8.3k Views 1 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.
  • A Offline
    A Offline
    agupta
    wrote on last edited by
    #1

    I am new to QT...

    I am trying to create an application which reads some data from the database... while retreving the data i want to show the progress bar.

    Since i don't know how much amount of time will application take for retreving the data, so i m using the following code for creating busy progress bar.

    @static int count;
    progressbar = new QProgressBar(this);
    @

    on the START button click event i m setting

    @progressBar->setMinimum(0);
    progressBar->setMaximum(0);
    progressBar->setValue(++count);@

    If user wants to stop the process in between i have given a CANCEL button
    on the CANCEL button click event i m setting

    @progressBar->reset();@

    But if I click on CANCEL button, the progress bar keeps on running, it doesn't reset.

    Please let me know if i m missing something here.

    [Edit: Code highlighting / Vass]

    Thank You,
    Aditya Gupta

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vsorokin
      wrote on last edited by
      #2

      Try on cancel this:
      @progressBar->setMaximum(100);
      progressBar->setValue(0);@
      For example.

      And wrap your code in @ tags please (right button on panel)

      --
      Vasiliy

      1 Reply Last reply
      0
      • A Offline
        A Offline
        agupta
        wrote on last edited by
        #3

        I used the following code:

        @void MainWindow::on_Start_Button_clicked()
        {
        progressBar->setMaximum(100);
        progressBar->setValue(0);
        }

        void MainWindow::on_Stop_Button_clicked()
        {
        progressBar->reset();
        }@

        It show the progess as 0% constantly.
        Please let me know what is wrong with the code.

        Thank You,
        Aditya Gupta

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          Hi,

          if you set minimum and maximum, you tell progress bar its limits.
          You aditionally have to set progressBar->setValue(amountDone); with amountDone = % done. then you will see progress.

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • A Offline
            A Offline
            agupta
            wrote on last edited by
            #5

            Hi....
            I don't know how much time will my application take for retreving the data, so in that case i m using the busy progressbar by setting maximum/minimum to 0/0.

            @void MainWindow::on_Start_Button_clicked()
            {
            static int count = 0;
            progressBar->setMaximum(0);
            progressBar->setMinimum(0);
            progressBar->setValue(count++);
            }
            void MainWindow::on_Stop_Button_clicked()
            {
            progressBar->reset();
            }@

            This shows me the busy progress bar, but if i click on Stop button the progress bar is not getting reset. Please let me know do i need to do anything else for resetting the progress bar.

            Thank You,
            Aditya Gupta

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #6

              if min = max = 0, the progress bar is busy. To stop that, set min = 0, max = 1.

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0
              • A Offline
                A Offline
                agupta
                wrote on last edited by
                #7

                Thanks... it works :)

                Thank You,
                Aditya Gupta

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andre
                  wrote on last edited by
                  #8

                  Or, you simply hide the progress bar, since nothing is progressing anyway.

                  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