-4

I am new in Qt , i want to show some progress in progress bar in side a for loop, progress bar should show progress from 0 to 100 How to do this ,plz help thanks.

rinku buragohain
  • 329
  • 2
  • 7
  • 15

2 Answers2

3

From the documentation (e.g. http://doc.qt.io/qt-4.8/qprogressbar.html)

A progress bar is used to give the user an indication of the progress of an operation [...]

You can specify the minimum and maximum number of steps with setMinimum() and setMaximum. The current number of steps is set with setValue().

So what you need is to construct a QProgressBar object, specify what the minimum and maximum should be and then call setValue(int value) to make it progress.

For your case:

QProgressBar progressBar;
progressBar.setMinimum(0);
progressBar.setMaximum(100);
// or as alternative to the two above, you could call
// progressBar.setRange(0,100);

for( int i = 0; i <100; ++i ) {
   progressBar.setValue(i);
}
Community
  • 1
  • 1
Erik
  • 2,137
  • 3
  • 25
  • 42
0
QProgressBar bar;

for(int i = 0; i < 100; ++i)
{
    bar.setValue(i);
}
AngryDuck
  • 4,358
  • 13
  • 57
  • 91