I need to show indefinite progress / Busy Effect in a QProgressBar that I am using. I read in the documentation, that it can be created by setting max and min values to 0. I tried the same, but could not get it right. I read about a possible bug that when I use the Plastique style, this effect does not take place. Is it possible to get the effect in some other way?
Asked
Active
Viewed 837 times
0
-
loop it: `if(progressBar->value == 100) progressBar = 0`; – SingerOfTheFall Jul 12 '12 at 13:07
2 Answers
0
One (not necessarily C++) solution could be to just display an animated GIF that shows a running progress bar?

YePhIcK
- 5,816
- 2
- 27
- 52
0
I've had this problem too! What I found is that if you make sure the work is done in a working thread, rather than the main thread, it works better. But sadly, you will still have some times where the progress bar shows weird stuff.

PierreBdR
- 42,120
- 10
- 46
- 62
-
1This "weird stuff" is likely due to your own code being reentered. `QProgressBar::setValue` is a persona-non-grata: it calls `QApplication::processEvents()` behind your back. Thus it can [reenter the very slot you called it from](http://stackoverflow.com/a/11433796/1329652). See that answer for a little side-note about run-to-completion code, with some practical references. The Qt I use is always modified with a patch that removes `processEvents()` from progress bar's `setValue()`. It's your own job to make sure that code that runs in the GUI thread always does short run-to-completion jobs. – Kuba hasn't forgotten Monica Jul 12 '12 at 22:46
-
@KubaOber No, it cannot be. I never have problems when I call `QProgressBar::setValue`, I have problems only if I don't call it (because this is an indefinite progress bar). Also, I always use worker threads when working with progress bars (it works much better), so the GUI thread does close to nothing. – PierreBdR Jul 13 '12 at 08:13
-
When you do work in the GUI thread, you most likely block it for long periods of time. You can instrument the event loop [as I described in another answer](http://stackoverflow.com/a/11000873/1329652) and verify if that's the case. – Kuba hasn't forgotten Monica Jul 13 '12 at 10:03
-
@KubaOber As I said, no work is done in the GUI thread! All the work is done in the worker thread. So I don't understand your point. – PierreBdR Jul 13 '12 at 12:07
-
Well, you said that you had the probem where it'd work better if the work was done in the non-gui thread. – Kuba hasn't forgotten Monica Jul 14 '12 at 20:52
-
@KubaOber No, I said that, even if I perform the work in a separate (non-gui) thread, I still have problems sometimes. – PierreBdR Jul 17 '12 at 12:26