×
Namespaces

Variants
Actions
Revision as of 21:56, 9 September 2009 by nayan_trivedi (Talk | contribs)

How to use QProgressBar in Qt

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Emulator
Compatibility
Platform(s): S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition
Symbian
Article
Keywords: QProgressBar,QSpinBox
Created: (04 Jan 2009)
Last edited: nayan_trivedi (09 Sep 2009)
{{{width}}}

Contents

Overview

This code snippet demonstrates how to use a QProgressBar in Qt for S60.

Various Functions

  • This display the current completed percentage in progress bar.
bar->setVisible(1);
Qtprogress2.jpg
  • This property is used to invert the direction of the progress in progress bar.
bar->setInvertedAppearance(1);
SpinInvert.JPG
  • This function is used for the orientation of progress bar.
bar->setOrientation(Qt::vertical);

Progressbar1.JPG

Preconditions


Header file

#ifndef PROGRESSBAR_H
#define PROGRESSBAR_H
 
#include <QtGui/QWidget>
#include "ui_progressbar.h"
#include <QProgressBar>
#include <QSpinBox>
#include <QVBoxLayout>
 
class progressbar : public QWidget
{
Q_OBJECT
 
public:
progressbar(QWidget *parent = 0);
~progressbar();
 
private:
QWidget* win;
QVBoxLayout* layout;
QProgressBar* bar;
QSpinBox* spin;
};
 
#endif // PROGRESSBAR_H


Source file

#include "progressbar.h"
 
progressbar::progressbar(QWidget *parent)
: QWidget(parent)
{
win = new QWidget(this);
win->setWindowTitle(("LCD Number"),this);
layout = new QVBoxLayout(this);
bar = new QProgressBar(this);
spin = new QSpinBox(this);
spin->setMaximum(99);
spin->setMinimum(0);
bar->resize(200,25);
bar->setOrientation(Qt::Horizontal);//Orientation can also be vertical
bar->setRange(0,99);
connect(spin , SIGNAL(valueChanged(int)), bar, SLOT(setValue(int)));
layout->addWidget(spin,Qt::AlignCenter);
 
layout->addWidget(bar,Qt::AlignCenter);
win->setLayout(layout);
win->showMaximized();
}
 
progressbar::~progressbar()
{
// No need to delete any object that has a parent which is properly deleted.
}


PostConditions

  • Here as you change the value of the spinbox progress bar will also changed.

Qtprogress1.jpg

  • Screen shot at 40% progress

Qtprogress2.jpg

Example

356 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×