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. [Solved] QProgressBar not getting updated.

[Solved] QProgressBar not getting updated.

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 5.4k Views
  • 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 Offline
    S Offline
    Sidii
    wrote on last edited by
    #1

    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
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sidii
        wrote on last edited by
        #3

        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
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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
          0
          • M Offline
            M Offline
            maximus
            wrote on last edited by
            #5

            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
            0
            • S Offline
              S Offline
              Sidii
              wrote on last edited by
              #6

              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
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved