Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.
How to use QProgressBar in Qt
This code snippet demonstrates how to use a QProgressBar in Qt.
- This display the current completed percentage in progress bar.
- This property is used to invert the direction of the progress in progress bar.
- This function is used for the orientation of progress bar.
class progressbar : public QWidget
progressbar(QWidget *parent = 0);
#endif // PROGRESSBAR_H
win = new QWidget(this);
layout = new QVBoxLayout(this);
bar = new QProgressBar(this);
spin = new QSpinBox(this);
bar->setOrientation(Qt::Horizontal);//Orientation can also be vertical
connect(spin, SIGNAL(valueChanged(int)), bar, SLOT(setValue(int)));
// No need to delete any object that has a parent which is properly deleted.
- Here as you change the value of the spinbox progress bar will also changed.
- Screen shot at 40% progress
- Download the working example from this link: Progressbar.zip