Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QProgressBar Class Reference

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

 #include <QProgressBar>

Inherits: QWidget.

Public Types

enum Direction { TopToBottom, BottomToTop }

Properties

  • 58 properties inherited from QWidget
  • 1 property inherited from QObject

Public Functions

QProgressBar ( QWidget * parent = 0 )
Qt::Alignment alignment () const
QString format () const
bool invertedAppearance ()
bool invertedAppearance () const
bool isTextVisible () const
int maximum () const
int minimum () const
Qt::Orientation orientation () const
void setAlignment ( Qt::Alignment alignment )
void setFormat ( const QString & format )
void setInvertedAppearance ( bool invert )
void setTextDirection ( QProgressBar::Direction textDirection )
void setTextVisible ( bool visible )
virtual QString text () const
QProgressBar::Direction textDirection ()
QProgressBar::Direction textDirection () const
int value () const

Reimplemented Public Functions

virtual QSize minimumSizeHint () const
virtual QSize sizeHint () const
  • 217 public functions inherited from QWidget
  • 29 public functions inherited from QObject
  • 13 public functions inherited from QPaintDevice

Public Slots

void reset ()
void setMaximum ( int maximum )
void setMinimum ( int minimum )
void setOrientation ( Qt::Orientation )
void setRange ( int minimum, int maximum )
void setValue ( int value )
  • 19 public slots inherited from QWidget
  • 1 public slot inherited from QObject

Signals

void valueChanged ( int value )

Protected Functions

void initStyleOption ( QStyleOptionProgressBar * option ) const

Reimplemented Protected Functions

virtual bool event ( QEvent * e )
virtual void paintEvent ( QPaintEvent * )
  • 37 protected functions inherited from QWidget
  • 7 protected functions inherited from QObject
  • 1 protected function inherited from QPaintDevice

Additional Inherited Members

  • 4 static public members inherited from QWidget
  • 5 static public members inherited from QObject
  • 1 protected slot inherited from QWidget

Detailed Description

The QProgressBar widget provides a horizontal or vertical 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 set it up by specifying the minimum and maximum possible step values, and it will display the percentage of steps that have been completed when you later give it the current step value. The percentage is calculated by dividing the progress (value() - minimum()) divided by maximum() - minimum().

You can specify the minimum and maximum number of steps with setMinimum() and setMaximum. The current number of steps is set with setValue(). The progress bar can be rewound to the beginning with reset().

If minimum and maximum both are set to 0, the bar shows a busy indicator instead of a percentage of steps. This is useful, for example, when using QFtp or QNetworkAccessManager to download items when they are unable to determine the size of the item being downloaded.

Screenshot of a Macintosh style progress barA progress bar shown in the Macintosh widget style.
Screenshot of a Windows XP style progress barA progress bar shown in the Windows XP widget style.
Screenshot of a Plastique style progress barA progress bar shown in the Plastique widget style.

See also QProgressDialog and GUI Design Handbook: Progress Indicator.

Member Type Documentation

enum QProgressBar::Direction

Specifies the reading direction of the text for vertical progress bars.

ConstantValueDescription
QProgressBar::TopToBottom0The text is rotated 90 degrees clockwise.
QProgressBar::BottomToTop1The text is rotated 90 degrees counter-clockwise.

Note that whether or not the text is drawn is dependent on the style. Currently CDE, CleanLooks, Motif, and Plastique draw the text. Mac, Windows and WindowsXP style do not.

This enum was introduced or modified in Qt 4.1.

See also textDirection.

Property Documentation

alignment : Qt::Alignment

This property holds the alignment of the progress bar.

Access functions:

Qt::Alignment alignment () const
void setAlignment ( Qt::Alignment alignment )

format : QString

This property holds the string used to generate the current text.

%p - is replaced by the percentage completed. %v - is replaced by the current value. %m - is replaced by the total number of steps.

The default value is "%p%".

This property was introduced in Qt 4.2.

Access functions:

QString format () const
void setFormat ( const QString & format )

See also text().

invertedAppearance : bool

This property holds whether or not a progress bar shows its progress inverted.

If this property is false, the progress bar grows in the other direction (e.g. from right to left). By default, the progress bar is not inverted.

This property was introduced in Qt 4.1.

Access functions:

bool invertedAppearance ()
bool invertedAppearance () const
void setInvertedAppearance ( bool invert )

See also orientation and layoutDirection.

maximum : int

This property holds the progress bar's maximum value.

When setting this property, the minimum is adjusted if necessary to ensure that the range remains valid. If the current value falls outside the new range, the progress bar is reset with reset().

Access functions:

int maximum () const
void setMaximum ( int maximum )

minimum : int

This property holds the progress bar's minimum value.

When setting this property, the maximum is adjusted if necessary to ensure that the range remains valid. If the current value falls outside the new range, the progress bar is reset with reset().

Access functions:

int minimum () const
void setMinimum ( int minimum )

orientation : Qt::Orientation

This property holds the orientation of the progress bar.

The orientation must be Qt::Horizontal (the default) or Qt::Vertical.

This property was introduced in Qt 4.1.

Access functions:

Qt::Orientation orientation () const
void setOrientation ( Qt::Orientation )

See also invertedAppearance and textDirection.

text : const QString

This property holds the descriptive text shown with the progress bar.

The text returned is the same as the text displayed in the center (or in some styles, to the left) of the progress bar.

The progress shown in the text may be smaller than the minimum value, indicating that the progress bar is in the "reset" state before any progress is set.

In the default implementation, the text either contains a percentage value that indicates the progress so far, or it is blank because the progress bar is in the reset state.

Access functions:

virtual QString text () const

textDirection : Direction

This property holds the reading direction of the text for vertical progress bars.

This property has no impact on horizontal progress bars. By default, the reading direction is QProgressBar::TopToBottom.

This property was introduced in Qt 4.1.

Access functions:

QProgressBar::Direction textDirection ()
QProgressBar::Direction textDirection () const
void setTextDirection ( QProgressBar::Direction textDirection )

See also orientation and textVisible.

textVisible : bool

This property holds whether the current completed percentage should be displayed.

This property may be ignored by the style (e.g., QMacStyle never draws the text).

Access functions:

bool isTextVisible () const
void setTextVisible ( bool visible )

See also textDirection.

value : int

This property holds the progress bar's current value.

Attempting to change the current value to one outside the minimum-maximum range has no effect on the current value.

Access functions:

int value () const
void setValue ( int value )

Notifier signal:

void valueChanged ( int value )

Member Function Documentation

QProgressBar::QProgressBar ( QWidget * parent = 0 )

Constructs a progress bar with the given parent.

By default, the minimum step value is set to 0, and the maximum to 100.

See also setRange().

bool QProgressBar::event ( QEvent * e ) [virtual protected]

Reimplemented from QObject::event().

void QProgressBar::initStyleOption ( QStyleOptionProgressBar * option ) const [protected]

Initialize option with the values from this QProgressBar. This method is useful for subclasses when they need a QStyleOptionProgressBar or QStyleOptionProgressBarV2, but don't want to fill in all the information themselves. This function will check the version of the QStyleOptionProgressBar and fill in the additional values for a QStyleOptionProgressBarV2.

See also QStyleOption::initFrom().

QSize QProgressBar::minimumSizeHint () const [virtual]

Reimplemented from QWidget::minimumSizeHint().

void QProgressBar::paintEvent ( QPaintEvent * ) [virtual protected]

Reimplemented from QWidget::paintEvent().

void QProgressBar::reset () [slot]

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

void QProgressBar::setRange ( int minimum, int maximum ) [slot]

Sets the progress bar's minimum and maximum values to minimum and maximum respectively.

If maximum is smaller than minimum, minimum becomes the only legal value.

If the current value falls outside the new range, the progress bar is reset with reset().

See also minimum and maximum.

QSize QProgressBar::sizeHint () const [virtual]

Reimplemented from QWidget::sizeHint().

void QProgressBar::valueChanged ( int value ) [signal]

This signal is emitted when the value shown in the progress bar changes. value is the new value shown by the progress bar.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Quarterly au hasard

Logo

Réordonner les boutons

Qt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.7-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web