Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. ProgressBar in Qt Creator updates badly after removing text
Forum Updated to NodeBB v4.3 + New Features

ProgressBar in Qt Creator updates badly after removing text

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
4 Posts 2 Posters 364 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.
  • J Offline
    J Offline
    JMEs
    wrote on last edited by Chris Kawa
    #1

    Hi, I'm sorry if this isn't the right place to ask this.

    I'm designing an interface in Qt Creator where I receive data from Arduino every 100 ms.

    I've implemented several ProgressBars which work just fine but now I have to add one which doesn't show the percentage, so I set to false the TextVisible property. The problem is that now the progressBar doesn't update everytime it receives new data and works a bit clunky, unlike when the text percentage was still visible.

    I've made a short video comparing 2 progressBars receiving the same data, where I set the TextVisible property in one of them to false when the progress is >50% so you can clearly see the slow down.

    I update their values at the same time like this:

    if(valor4 > 100){
            ui->progressBar_1_Bat_3->setTextVisible(false);
            qDebug()<<"Invisible";
          }else if(valor4 <= 100){
            ui->progressBar_1_Bat_3->setTextVisible(true);
            qDebug()<<"Visible";
          }
    
          ui->progressBar_1_Bat_3->setValue(valor4 * 100 / 200);
          ui->progressBar_1_Bat_4->setValue(valor4 * 100 / 200);
    

    There is no other place in the code where they are mentioned and one is copy-pasted from the other so every other property should be the same.

    ProgressBar.gif

    You can see how the bottom ProgressBar starts to lag behind after removing text and then works fine after re-adding it.

    Is this normal behaviour? Has anyone else had this problem?

    Thank you very much.

    JonBJ 1 Reply Last reply
    0
    • J JMEs

      Hi, I'm sorry if this isn't the right place to ask this.

      I'm designing an interface in Qt Creator where I receive data from Arduino every 100 ms.

      I've implemented several ProgressBars which work just fine but now I have to add one which doesn't show the percentage, so I set to false the TextVisible property. The problem is that now the progressBar doesn't update everytime it receives new data and works a bit clunky, unlike when the text percentage was still visible.

      I've made a short video comparing 2 progressBars receiving the same data, where I set the TextVisible property in one of them to false when the progress is >50% so you can clearly see the slow down.

      I update their values at the same time like this:

      if(valor4 > 100){
              ui->progressBar_1_Bat_3->setTextVisible(false);
              qDebug()<<"Invisible";
            }else if(valor4 <= 100){
              ui->progressBar_1_Bat_3->setTextVisible(true);
              qDebug()<<"Visible";
            }
      
            ui->progressBar_1_Bat_3->setValue(valor4 * 100 / 200);
            ui->progressBar_1_Bat_4->setValue(valor4 * 100 / 200);
      

      There is no other place in the code where they are mentioned and one is copy-pasted from the other so every other property should be the same.

      ProgressBar.gif

      You can see how the bottom ProgressBar starts to lag behind after removing text and then works fine after re-adding it.

      Is this normal behaviour? Has anyone else had this problem?

      Thank you very much.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @JMEs
      Not sure whether either of these will help:

      • Only call setTextVisible() if it needs changing from current state. (Qt code internals may make this irrelevant, but just in case.)

      • Try calling update() after setValue().

      • Assuming that makes no difference, try calling repaint() there. At least for development to see if that resolves the issue, not sure about long-term for efficiency.

      J 1 Reply Last reply
      3
      • JonBJ JonB

        @JMEs
        Not sure whether either of these will help:

        • Only call setTextVisible() if it needs changing from current state. (Qt code internals may make this irrelevant, but just in case.)

        • Try calling update() after setValue().

        • Assuming that makes no difference, try calling repaint() there. At least for development to see if that resolves the issue, not sure about long-term for efficiency.

        J Offline
        J Offline
        JMEs
        wrote on last edited by
        #3

        @JonB Thank you very much. Calling update() after setvalue() seems to have solved it!

        Here is how it looks now:

        Progressbar Fixed.gif

        Thank you very much!

        JonBJ 1 Reply Last reply
        1
        • J JMEs

          @JonB Thank you very much. Calling update() after setvalue() seems to have solved it!

          Here is how it looks now:

          Progressbar Fixed.gif

          Thank you very much!

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @JMEs
          This is good. But why you should need to call update() here after changing value (without text) I do not know.... Perhaps under certain circumstances even when value changes so that progressbar will move Qt internals think it has not changed/does not need redisplaying, whereas when the text value number changes it does recognise that needs redisplaying. (Your original pic makes it look like the progressbar on its own has maybe 10 "chunks" and it only redisplays when these change, if you use text it does not do it by "chunks", and you have to call update() if you wish the progressbar on its own to update every time?)

          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