Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QProgressBar Class Reference

The QProgressBar widget provides a horizontal progress bar. More...

    #include <QProgressBar>

Inherits QFrame.

- List of all members, including inherited members
- Obsolete members

### Writable Properties

- centerIndicator : bool
- indicatorFollowsStyle : bool
- percentageVisible : bool

- progress : int
- totalSteps : int

- 5 writable properties inherited from QFrame
- 33 writable properties inherited from QWidget
- 1 writable property inherited from QObject

### Read-Only Properties

- progressString : QString

- 1 read-only property inherited from QFrame
- 24 read-only properties inherited from QWidget

### Public Functions

- QProgressBar ( QWidget * parent = 0, Qt::WFlags f = 0 )
- QProgressBar ( int totalSteps, QWidget * parent = 0, Qt::WFlags f = 0 )

- 2 public functions inherited from QFrame
- 83 public functions inherited from QWidget
- 24 public functions inherited from QObject
- 2 public functions inherited from QPaintDevice

### Public Slots

- void reset ()
- virtual void setProgress ( int progress )
- void setProgress ( int progress, int totalSteps )
- virtual void setTotalSteps ( int totalSteps )

- 16 public slots inherited from QWidget
- 1 public slot inherited from QObject

### Signals

- 1 signal inherited from QObject

### Static Public Members

- 4 static public members inherited from QWidget
- 4 static public members inherited from QObject

### Protected Functions

- virtual bool setIndicator ( QString & indicator, int progress, int totalSteps )

- 44 protected functions inherited from QWidget
- 9 protected functions inherited from QObject

## Detailed Description

The QProgressBar widget provides a horizontal progress bar.

A progress bar is used to give the user an indication of the progress of an operation and to reassure them that the application is still running.

The progress bar uses the concept of steps; you give it the total number of steps and the number of steps completed so far and it will display the percentage of steps that have been completed. You can specify the total number of steps in the constructor or later with setTotalSteps(). The current number of steps is set with setProgress(). The progress bar can be rewound to the beginning with reset().

If the total is given as 0 the progress bar shows a busy indicator instead of a percentage of steps. This is useful, for example, when using QFtp or QHttp to download items when they are unable to determine the size of the item being downloaded.

GUI Design Handbook: Progress Indicator

See also QProgressDialog and QProgressDialog.

## Property Documentation

### centerIndicator : bool

This property holds whether the indicator string should be centered.

Changing this property sets QProgressBar::indicatorFollowsStyle to false. The default is true.

Access functions:

- bool centerIndicator () const
- void setCenterIndicator ( bool on )

### indicatorFollowsStyle : bool

This property holds whether the display of the indicator string should follow the GUI style.

The default is true.

Access functions:

- bool indicatorFollowsStyle () const
- void setIndicatorFollowsStyle ( bool )

See also centerIndicator.

### percentageVisible : bool

This property holds whether the current progress value is displayed.

The default is true.

Access functions:

- bool percentageVisible () const
- void setPercentageVisible ( bool )

See also centerIndicator and indicatorFollowsStyle.

### progress : int

This property holds the current amount of progress.

This property is -1 if progress counting has not started.

Access functions:

- int progress () const
- virtual void setProgress ( int progress )
- void setProgress ( int progress, int totalSteps )

### progressString : QString

This property holds the amount of progress as a string.

This property is an empty string if progress counting has not started.

Access functions:

- const QString & progressString () const

### totalSteps : int

This property holds the total number of steps.

If totalSteps is 0, the progress bar will display a busy indicator.

Access functions:

- int totalSteps () const
- virtual void setTotalSteps ( int totalSteps )

See also totalSteps().

## Member Function Documentation

### QProgressBar::QProgressBar ( QWidget * parent = 0, Qt::WFlags f = 0 )

Constructs a progress bar.

The total number of steps is set to 100 by default.

The parent, and widget flags, f, are passed on to the QFrame::QFrame() constructor.

See also setTotalSteps().

### QProgressBar::QProgressBar ( int totalSteps, QWidget * parent = 0, Qt::WFlags f = 0 )

Constructs a progress bar.

The totalSteps is the total number of steps that need to be completed for the operation which this progress bar represents. For example, if the operation is to examine 50 files, this value would be 50. Before examining the first file, call setProgress(0); call setProgress(50) after examining the last file.

The parent, and widget flags, f, are passed to the QFrame::QFrame() constructor.

See also setTotalSteps() and setProgress().

### void QProgressBar::reset () `[slot]`

Reset the progress bar. The progress bar "rewinds" and shows no progress.

### bool QProgressBar::setIndicator ( QString & indicator, int progress, int totalSteps ) `[virtual protected]`

This method is called to generate the text displayed in the center (or in some styles, to the left) of the progress bar.

The progress may be negative, indicating that the progress bar is in the "reset" state before any progress is set.

The default implementation is the percentage of completion or blank in the reset state. The percentage is calculated based on the progress and totalSteps. You can set the indicator text if you wish.

To allow efficient repainting of the progress bar, this method should return false if the string is unchanged from the last call to this function.