
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQStatusBar class provides a horizontal bar suitable for presenting status information.More...
| Header: | #include <QStatusBar> |
| Inherits: | QWidget |
| QStatusBar(QWidget * parent = 0) | |
| virtual | ~QStatusBar() |
| void | addPermanentWidget(QWidget * widget, int stretch = 0) |
| void | addWidget(QWidget * widget, int stretch = 0) |
| QString | currentMessage() const |
| int | insertPermanentWidget(int index, QWidget * widget, int stretch = 0) |
| int | insertWidget(int index, QWidget * widget, int stretch = 0) |
| bool | isSizeGripEnabled() const |
| void | removeWidget(QWidget * widget) |
| void | setSizeGripEnabled(bool) |
| void | clearMessage() |
| void | showMessage(const QString & message, int timeout = 0) |
| void | messageChanged(const QString & message) |
| void | hideOrShow() |
| void | reformat() |
| virtual bool | event(QEvent * e) |
| virtual void | paintEvent(QPaintEvent * event) |
| virtual void | resizeEvent(QResizeEvent * e) |
| virtual void | showEvent(QShowEvent *) |
TheQStatusBar 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 aQMainWindow object.QMainWindow provides a main application window, with a menu bar, tool bars, dock widgetsand a status bar around a large central widget. The status bar can be retrieved using theQMainWindow::statusBar() function, and replaced using theQMainWindow::setStatusBar() function.
Use theshowMessage() slot to display atemporary message:
void MainWindow::createStatusBar(){ statusBar()->showMessage(tr("Ready"));}
To remove a temporary message, use theclearMessage() slot, or set a time limit when callingshowMessage(). For example:
void MainWindow::print(){#ifndef QT_NO_PRINTDIALOGQTextDocument*document= textEdit->document();QPrinter printer;QPrintDialog*dlg=newQPrintDialog(&printer,this);if (dlg->exec()!=QDialog::Accepted)return; document->print(&printer); statusBar()->showMessage(tr("Ready"),2000);#endif}
Use thecurrentMessage() function to retrieve the temporary message currently shown. TheQStatusBar class also provide themessageChanged() signal which is emitted whenever the temporary status message changes.
Normal andPermanent messages are displayed by creating a small widget (QLabel,QProgressBar or evenQToolButton) and then adding it to the status bar using theaddWidget() or theaddPermanentWidget() function. Use theremoveWidget() function to remove such messages from the status bar.
statusBar()->addWidget(new MyReadWriteIndication);
By defaultQStatusBar provides aQSizeGrip in the lower-right corner. You can disable it using thesetSizeGripEnabled() function. Use theisSizeGripEnabled() function to determine the current status of the size grip.

See alsoQMainWindow,QStatusTipEvent,GUI Design Handbook: Status Bar, andApplication Example.
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) |
Constructs a status bar with a size grip and the givenparent.
See alsosetSizeGripEnabled().
[virtual]QStatusBar::~QStatusBar()Destroys this status bar and frees any allocated resources and child widgets.
Adds the givenwidget permanently to this status bar, reparenting the widget if it isn't already a child of thisQStatusBar object. Thestretch parameter is used to compute a suitable size for the givenwidget 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.
See alsoinsertPermanentWidget(),removeWidget(), andaddWidget().
Adds the givenwidget to this status bar, reparenting the widget if it isn't already a child of thisQStatusBar object. Thestretch parameter is used to compute a suitable size for the givenwidget 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 (seeaddPermanentWidget()) and may be obscured by temporary messages.
See alsoinsertWidget(),removeWidget(), andaddPermanentWidget().
[slot]void QStatusBar::clearMessage()Removes any temporary message being shown.
See alsocurrentMessage(),showMessage(), andremoveWidget().
Returns the temporary message currently shown, or an empty string if there is no such message.
See alsoshowMessage().
[virtual protected]bool QStatusBar::event(QEvent * e)Reimplemented fromQObject::event().
[protected]void QStatusBar::hideOrShow()Ensures that the right widgets are visible.
Used by theshowMessage() andclearMessage() functions.
Inserts the givenwidget at the givenindex permanently to this status bar, reparenting the widget if it isn't already a child of thisQStatusBar object. Ifindex is out of range, the widget is appended (in which case it is the actual index of the widget that is returned).
Thestretch parameter is used to compute a suitable size for the givenwidget 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.
This function was introduced in Qt 4.2.
See alsoaddPermanentWidget(),removeWidget(), andaddWidget().
Inserts the givenwidget at the givenindex to this status bar, reparenting the widget if it isn't already a child of thisQStatusBar object. Ifindex is out of range, the widget is appended (in which case it is the actual index of the widget that is returned).
Thestretch parameter is used to compute a suitable size for the givenwidget 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 (seeaddPermanentWidget()) and may be obscured by temporary messages.
This function was introduced in Qt 4.2.
See alsoaddWidget(),removeWidget(), andaddPermanentWidget().
[signal]void QStatusBar::messageChanged(constQString & message)This signal is emitted whenever the temporary status message changes. The new temporary message is passed in themessage parameter which is a null-string when the message has been removed.
See alsoshowMessage() andclearMessage().
[virtual protected]void QStatusBar::paintEvent(QPaintEvent * event)Reimplemented fromQWidget::paintEvent().
Shows the temporary message, if appropriate, in response to the paintevent.
[protected]void QStatusBar::reformat()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.
Removes the specifiedwidget from the status bar.
Note:This function does not delete the widget buthides it. To add the widget again, you must call both theaddWidget() andshow() functions.
See alsoaddWidget(),addPermanentWidget(), andclearMessage().
[virtual protected]void QStatusBar::resizeEvent(QResizeEvent * e)Reimplemented fromQWidget::resizeEvent().
[virtual protected]void QStatusBar::showEvent(QShowEvent *)Reimplemented fromQWidget::showEvent().
[slot]void QStatusBar::showMessage(constQString & message,int timeout = 0)Hides the normal status indications and displays the givenmessage for the specified number of milli-seconds (timeout). Iftimeout is 0 (default), themessage remains displayed until theclearMessage() slot is called or until the showMessage() slot is called again to change the message.
Note that showMessage() is called to show temporary explanations of tool tip texts, so passing atimeout of 0 is not sufficient to display apermanent message.
See alsomessageChanged(),currentMessage(), andclearMessage().
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.