ProgressBar in Qt Creator updates badly after removing text
-
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.
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.
-
@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()
aftersetValue()
. -
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.
-
-
@JMEs
This is good. But why you should need to callupdate()
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 callupdate()
if you wish the progressbar on its own to update every time?)