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. Showing negative values of axis on the progress bar
Forum Updated to NodeBB v4.3 + New Features

Showing negative values of axis on the progress bar

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt5progress bar
9 Posts 4 Posters 1.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.
  • D Offline
    D Offline
    deleted286
    wrote on last edited by
    #1

    Hi everyone. I have 8 different progress bar. In the code below, im showing the positive values of my array. I want to display negative values also. How can i do it?
    When i put else and write the other progress bar on gui, it didnt work true

        ```
    
    if(dizi[1] > 0  || dizi[2] > 0 || dizi[3] > 0  || dizi[4] > 0)
            {
                ui->progressBarAx->setValue(dizi[1]);
                ui->progressBarAy->setValue(dizi[2]);
                ui->progressBarBx->setValue(dizi[3]);
                ui->progressBarBy->setValue(dizi[4]);
    
            }
    
    J.HilkJ S 2 Replies Last reply
    0
    • D deleted286

      Hi everyone. I have 8 different progress bar. In the code below, im showing the positive values of my array. I want to display negative values also. How can i do it?
      When i put else and write the other progress bar on gui, it didnt work true

          ```
      
      if(dizi[1] > 0  || dizi[2] > 0 || dizi[3] > 0  || dizi[4] > 0)
              {
                  ui->progressBarAx->setValue(dizi[1]);
                  ui->progressBarAy->setValue(dizi[2]);
                  ui->progressBarBx->setValue(dizi[3]);
                  ui->progressBarBy->setValue(dizi[4]);
      
              }
      
      J.HilkJ Online
      J.HilkJ Online
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @suslucoder well, have you set your minimum of the progress bar beforehand to a value, that is below 0?


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      D 1 Reply Last reply
      0
      • J.HilkJ J.Hilk

        @suslucoder well, have you set your minimum of the progress bar beforehand to a value, that is below 0?

        D Offline
        D Offline
        deleted286
        wrote on last edited by
        #3

        @J-Hilk It should be between -500 and 0, so
        can i put this

             ```
        
        ui->progressBarAxNeg->setMinimum(-500);
                 ui->progressBarAxNeg->setMaximum(0);
        
        J.HilkJ 1 Reply Last reply
        0
        • D deleted286

          @J-Hilk It should be between -500 and 0, so
          can i put this

               ```
          
          ui->progressBarAxNeg->setMinimum(-500);
                   ui->progressBarAxNeg->setMaximum(0);
          
          J.HilkJ Online
          J.HilkJ Online
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @suslucoder said in Showing negative values of axis on the progress bar:

          can i put this

          AFAIK yes, why don't you try it ?


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          D 1 Reply Last reply
          1
          • J.HilkJ J.Hilk

            @suslucoder said in Showing negative values of axis on the progress bar:

            can i put this

            AFAIK yes, why don't you try it ?

            D Offline
            D Offline
            deleted286
            wrote on last edited by
            #5

            @J-Hilk It doesnt work true still.

            J.HilkJ JonBJ 2 Replies Last reply
            0
            • D deleted286

              @J-Hilk It doesnt work true still.

              J.HilkJ Online
              J.HilkJ Online
              J.Hilk
              Moderators
              wrote on last edited by
              #6

              @suslucoder ?

              int main(int argc, char *argv[])
              {
                  QApplication app(argc, argv);
              
                  QProgressBar pbar;
              
                  pbar.setRange( -50,50);
                  pbar.setValue(-50);
                  pbar.setOrientation(Qt::Horizontal);
              
                  pbar.show();
                  pbar.resize(200,50);
              
                  QTimer t;
                  QObject::connect(&t, &QTimer::timeout, [&t, &pbar]()->void{
                      auto nextValue = pbar.value()+1;
                      if(nextValue > pbar.maximum()){
                          t.stop();
                          return;
                      }
                      pbar.setValue(nextValue);
                  });
                  t.start(500);
              
                  return  app.exec();
              }
              

              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              1 Reply Last reply
              2
              • D deleted286

                @J-Hilk It doesnt work true still.

                JonBJ Online
                JonBJ Online
                JonB
                wrote on last edited by
                #7

                @suslucoder said in Showing negative values of axis on the progress bar:

                It doesnt work true still.

                Show your code.

                1 Reply Last reply
                0
                • D deleted286

                  Hi everyone. I have 8 different progress bar. In the code below, im showing the positive values of my array. I want to display negative values also. How can i do it?
                  When i put else and write the other progress bar on gui, it didnt work true

                      ```
                  
                  if(dizi[1] > 0  || dizi[2] > 0 || dizi[3] > 0  || dizi[4] > 0)
                          {
                              ui->progressBarAx->setValue(dizi[1]);
                              ui->progressBarAy->setValue(dizi[2]);
                              ui->progressBarBx->setValue(dizi[3]);
                              ui->progressBarBy->setValue(dizi[4]);
                  
                          }
                  
                  S Offline
                  S Offline
                  SimonSchroeder
                  wrote on last edited by
                  #8

                  @suslucoder said in Showing negative values of axis on the progress bar:

                  if(dizi[1] > 0 || dizi[2] > 0 || dizi[3] > 0 || dizi[4] > 0)

                  If this is from your code, then it will only update the progress bars if at least one of the 4 values is greater 0. Furthermore, if your array/vector dizi has 4 entries you need to use indices 0 through 3.

                  D 1 Reply Last reply
                  1
                  • S SimonSchroeder

                    @suslucoder said in Showing negative values of axis on the progress bar:

                    if(dizi[1] > 0 || dizi[2] > 0 || dizi[3] > 0 || dizi[4] > 0)

                    If this is from your code, then it will only update the progress bars if at least one of the 4 values is greater 0. Furthermore, if your array/vector dizi has 4 entries you need to use indices 0 through 3.

                    D Offline
                    D Offline
                    deleted286
                    wrote on last edited by
                    #9

                    @SimonSchroeder I want to update my progress bar, if one of these values greater than 0. For example if the dizi[1] > 0, update.

                    I dont want to see dizi[0]. Because of it i started from 1

                    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