You Are Here:

Community: Wiki

This page was last modified on 30 October 2009, at 15:47.

How to use QProgressBar in Qt for Symbian

From Forum Nokia Wiki

(Redirected from How to use QProgressBar)
Reviewer Approved   


ID ... Creation date 04 January 2009
Platform S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition Tested on devices Emulator
Category Qt for Symbian Subcategory


Keywords (APIs, classes, methods, functions): QProgressBar,QSpinBox

Overview

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

Various Functions

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

Image: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.

Image:Qtprogress1.jpg

  • Screen shot at 40% progress

Image:Qtprogress2.jpg

Example

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fComboBoE78E5fwithE5fcolorE5fpalettesE5finE5fE51tE5fforE5fSymbianX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZE71tQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qfnZuserE5ftagQSxE71tX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ