![]() |
Home · Overviews · Examples |
The QStatusBar class provides a horizontal bar suitable for presenting status information. More...
Inherits QWidget.
The QStatusBar class provides a horizontal bar suitable for presenting status information.
Each status indicator falls into one of three categories:
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.
Copyright © 2008 Trolltech | Trademarks | Qt Jambi 4.3.5_01 |