Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [Solved] QProgressBar not getting updated.

    General and Desktop
    4
    6
    4965
    Loading More Posts
    • 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.
    • S
      Sidii last edited by

      Hi All,

      I am facing one issue related to the QProgressBar.
      My QProgressBar is in the main GUI thread. One QLabel is also present.

      From one outside thread, i am emitting one signal which calls a slot of the Main program (GUI Main Thread) that in turns update both the QLabel and QProgressBar.

      The problem is that QLabel is updated everytime but there is no effect on QProgressBar.
      I have also used update() on progress bar but still it is not getting updated.

      Kindly let me know what can be done to resolve this.

      Thanks

      Siddharth

      1 Reply Last reply Reply Quote 0
      • A
        andreyc last edited by

        Could you show how did you connect QProgressBar and QLabel with the outside thread.

        1 Reply Last reply Reply Quote 0
        • S
          Sidii last edited by

          Dear Andreyc,

          Thanks for the reply.

          Here is the code:

          threadObject is an object of a Class derived from QThread.
          We emit the signal from this class only.

          In MainWindow Constructor we have written the connect statement:

          @connect(&threadObject,SIGNAL(updateIndex(QString)),this,SLOT(updateUI(QString)));@

          Here is the slot:

          @
          void MainWindow::updateUI(QString str)
          {

              ui->label_cl72->setText(str);
              ui->label_cl74->setText(str);
              ui->progressBar->setValue(str.toInt());
              //        qApp->processEvents();
              //        QCoreApplication::processEvents();
          

          }

          @

          Label is getting updated but Progress bar is not getting updated.

          Thanks

          Siddharth

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            Hi,

            What can str contain ? Thus are you sure that str.toInt() returns a valid value ?

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

            1 Reply Last reply Reply Quote 0
            • M
              maximus last edited by

              I would check with a few qDebug if you get a good value here :

              @ ui->progressBar->setValue(str.toInt());@

              Also make sure your progressBar has a minimum and maximum value that is valid relative to your "str" variable :
              minimum < str.toInt() < maximum
              if you set a value outside of the range, you won't see the QProgressBar change

              Good luck


              Free Indoor Cycling Software - https://maximumtrainer.com

              1 Reply Last reply Reply Quote 0
              • S
                Sidii last edited by

                Dear SGaist, Maximus,

                Thanks for the reply.

                Yes there was some problem with the argument:
                @
                ui->progressBar->setValue(str.toInt());
                @

                In the begining the str was double and then it was converted to the float and then to the string and again to the int. So everytime the value was getting 0.

                The connected hardware was sending the wrong values.

                Marking the thread as solved.

                Thanks

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post