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  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QStatusBar Class Reference
[QtGui module]

The QStatusBar class provides a horizontal bar suitable for presenting status information. More...

#include <QStatusBar>

Inherits QWidget.

Properties

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

Public Functions

  • 190 public functions inherited from QWidget
  • 28 public functions inherited from QObject
  • 12 public functions inherited from QPaintDevice

Public Slots

  • 17 public slots inherited from QWidget
  • 1 public slot inherited from QObject

Signals

Protected Functions

  • 39 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
  • 4 static public members inherited from QObject

Detailed Description

The QStatusBar class provides a horizontal bar suitable for presenting status information.

Each status indicator falls into one of three categories:

  • Temporary - briefly occupies most of the status bar. Used to explain tool tip texts or menu entries, for example.
  • Normal - occupies part of the status bar and may be hidden by temporary messages. Used to display the page and line number in a word processor, for example.
  • Permanent - is never hidden. Used for important mode indications, for example, some applications put a Caps Lock indicator in the status bar.

QStatusBar lets you display all three types of indicators.

Typically, a request for the status bar functionality occurs in relation to a QMainWindow object. QMainWindow provides a main application window, with a menu bar, tool bars, dock widgets and a status bar around a large central widget. The status bar can be retrieved using the QMainWindow::statusBar() function, and replaced using the QMainWindow::setStatusBar() function.

Use the showMessage() slot to display a temporary message:

    void MainWindow::createStatusBar()
    {
        statusBar()->showMessage(tr("Ready"));
    }

To remove a temporary message, use the clearMessage() slot, or set a time limit when calling showMessage(). For example:

    void MainWindow::print()
    {
        QTextDocument *document = textEdit->document();
        QPrinter printer;

        QPrintDialog *dlg = new QPrintDialog(&printer, this);
        if (dlg->exec() != QDialog::Accepted)
            return;

        document->print(&printer);

        statusBar()->showMessage(tr("Ready"), 2000);
    }

Use the currentMessage() function to retrieve the temporary message currently shown. The QStatusBar class also provide the messageChanged() signal which is emitted whenever the temporary status message changes.

Normal and Permanent messages are displayed by creating a small widget (QLabel, QProgressBar or even QToolButton) and then adding it to the status bar using the addWidget() or the addPermanentWidget() function. Use the removeWidget() function to remove such messages from the status bar.

    statusBar()->addWidget(new MyReadWriteIndication);

By default QStatusBar provides a QSizeGrip in the lower-right corner. You can disable it using the setSizeGripEnabled() function. Use the isSizeGripEnabled() function to determine the current status of the size grip.

A status bar shown in the Plastique widget style.

See also QMainWindow, QStatusTipEvent, and GUI Design Handbook: Status Bar.


Property Documentation

sizeGripEnabled : bool

This property holds whether the QSizeGrip in the bottom-right corner of the status bar is enabled.

The size grip is enabled by default.

Access functions:

  • bool isSizeGripEnabled () const
  • void setSizeGripEnabled ( bool )

Member Function Documentation

QStatusBar::QStatusBar ( QWidget * parent = 0 )

Constructs a status bar with a size grip and the given parent.

See also setSizeGripEnabled().

QStatusBar::~QStatusBar ()   [virtual]

Destroys this status bar and frees any allocated resources and child widgets.

void QStatusBar::addPermanentWidget ( QWidget * widget, int stretch = 0 )

Adds the given widget permanently to this status bar, reparenting the widget if it isn't already a child of this QStatusBar object. The stretch parameter is used to compute a suitable size for the given widget as the status bar grows and shrinks. The default stretch factor is 0, i.e giving the widget a minimum of space.

Permanently means that the widget may not be obscured by temporary messages. It is is located at the far right of the status bar.

Note that this function may cause some flicker.

See also removeWidget() and addWidget().

void QStatusBar::addWidget ( QWidget * widget, int stretch = 0 )

Adds the given widget to this status bar, reparenting the widget if it isn't already a child of this QStatusBar object. The stretch parameter is used to compute a suitable size for the given widget as the status bar grows and shrinks. The default stretch factor is 0, i.e giving the widget a minimum of space.

The widget is located to the far left of the first permanent widget (see addPermanentWidget()) and may be obscured by temporary messages.

Note that this function may cause some flicker.

See also removeWidget() and addPermanentWidget().

void QStatusBar::clearMessage ()   [slot]

Removes any temporary message being shown.

See also currentMessage(), showMessage(), and removeWidget().

QString QStatusBar::currentMessage () const

Returns the temporary message currently shown, or an empty string if there is no such message.

See also showMessage().

void QStatusBar::hideOrShow ()   [protected]

Ensures that the right widgets are visible.

Used by the showMessage() and clearMessage() functions.

void QStatusBar::messageChanged ( const QString & message )   [signal]

This signal is emitted whenever the temporary status message changes. The new temporary message is passed in the message parameter which is a null-string when the message has been removed.

See also showMessage() and clearMessage().

void QStatusBar::reformat ()   [protected]

Changes the status bar's appearance to account for item changes.

Special subclasses may need this function, but geometry management will usually take care of any necessary rearrangements.

void QStatusBar::removeWidget ( QWidget * widget )

Removes the specifed widget from the status bar (without deleting it).

This function may cause some flicker.

See also addWidget(), addPermanentWidget(), and clearMessage().

void QStatusBar::showMessage ( const QString & message, int timeout = 0 )   [slot]

Hides the normal status indications and displays the given message for the specified timeout milli-seconds (if non-zero), or until clearMessage() or another showMessage() is called, whichever occurs first.

See also messageChanged(), currentMessage(), and clearMessage().

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 94
  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. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 43
  4. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 9
Page suivante

Le Qt Labs au hasard

Logo

Génération de contenu dans des threads

Les Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. 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.1
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