PDA

View Full Version : QProgress bar - Busy Indicator - Strange behaviour



johnnyturbo3
27th April 2011, 08:43
I'm trying to add a Progress bar as a busy indicator. However, it's behaving strange - the 'progress' only goes a quarter of the way up the bar and then restarts at the beginning. I'm using the following code:

test.cpp

test::test()
{
QProgressBar *qProBar = new QProgressBar;
qProBar->setRange(0,0);

QVBoxLayout *mainLayout = new QVBoxLayout();
mainLayout->addWidget(qProBar);

setLayout(mainLayout);
}

test.h

class test : public QWidget
{
Q_OBJECT

public:
test();
~test();
};

I couldn't find any similar problems on the net, and the code is as minimal as it can get. Any ideas? Thanks in advance!

AlexSudnik
27th April 2011, 10:43
What's the point of setting the bar's range to 0 ? :confused:.

johnnyturbo3
27th April 2011, 11:50
http://doc.trolltech.com/latest/qprogressbar.html#details

"If minimum and maximum both are set to 0, the bar shows a busy indicator instead of a percentage of steps. This is useful, for example, when using QFtp or QNetworkAccessManager to download items when they are unable to determine the size of the item being downloaded."

AlexSudnik
27th April 2011, 13:38
Ah , now i see. Works fine for me though...indicator runs the whole path repeatedly. Do you have any problems with displaying other widgets or it only happens with QStatusBar?

johnnyturbo3
27th April 2011, 13:56
Strange. I'm using Visual Studio 2010. I tried running my app under Release rather than Debug and the progress bar works as expected.
Thanks anyway.