|  | Home · Overviews · Examples |

# QStatusBar Class Reference
[com.trolltech.qt.gui module]

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

Inherits `QWidget`.

## 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.

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