6.0.0-rc4Source

QStatusBar Class

The QStatusBar class is a bar for messages and small widgets at the bottom of a window. More…

Header#include <QStatusBar>
CMaketarget_link_libraries(app PRIVATE Nt::Widgets)
ModuleNt Widgets C++ Classes
InheritsQWidget

List of all members, including inherited members

Public Functions

QStatusBar(QWidget *parent = nullptr)
~QStatusBar()
voidaddWidget(QWidget *widget, int stretch = 0)
voidinsertWidget(int index, QWidget *widget, int stretch = 0)
voidaddPermanentWidget(QWidget *widget, int stretch = 0)
voidinsertPermanentWidget(int index, QWidget *widget, int stretch = 0)
voidremoveWidget(QWidget *widget)
QStringcurrentMessage() const
boolisSizeGripEnabled() const
voidsetSizeGripEnabled(bool enabled)

Reimplemented Public Functions

Public Slots

voidshowMessage(const QString &text, int timeout = 0)
voidclearMessage()

Signals

voidmessageChanged(const QString &message)

Reimplemented Protected Functions

voidpaintEvent(QPaintEvent *event)
voidresizeEvent(QResizeEvent *event)
voidtimerEvent(QTimerEvent *event)
voidchangeEvent(QEvent *event)

Detailed Description

A status bar shows a message, which goes away after a time or when it is cleared, and has widgets: the ones that addWidget() adds are on the left and hidden while a message is shown, and the ones that addPermanentWidget() adds are on the right and always there:

QStatusBar *bar = new QStatusBar(window);
bar->addPermanentWidget(new QLabel("Line 1, column 1"));
bar->showMessage("File saved", 3000);

A status bar with a message, and one with a widget on each side.

QStatusBar in the light color scheme

See also QLabel and QProgressBar.

Differences from Qt

There is no QMainWindow to have a status bar, so put it at the bottom of a layout. The size grip is not drawn: setSizeGripEnabled() is only a property. There is no reformat() and no hideOrShow(), and a message cannot be set by a QWidget::statusTip.

Member Function Documentation

[explicit] QStatusBar::QStatusBar(QWidget *parent = nullptr)

Constructs a status bar with no message and the given parent. It is as high as its widgets need, and as wide as its parent.

[override] QStatusBar::~QStatusBar()

Destroys the status bar.

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

Adds widget on the right, after the ones that are there, with the stretch factor. It is not hidden by a message.

See also insertPermanentWidget() and addWidget().

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

Adds widget on the left, after the ones that are there, with the stretch factor that says how much of the extra room it takes. It is hidden while a message is shown. The status bar makes it a child.

See also insertWidget() and addPermanentWidget().

[override, protected] void QStatusBar::changeEvent(QEvent *event)

Reimplements QWidget::changeEvent().

[slot] void QStatusBar::clearMessage()

Removes the message, and shows the widgets on the left again. Emits messageChanged() if there was a message.

See also showMessage().

QString QStatusBar::currentMessage() const

Returns the message that is shown, or an empty text if there is none.

See also showMessage().

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

Inserts widget among the widgets on the right, at index, with the given stretch factor.

See also addPermanentWidget().

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

Inserts widget among the widgets on the left, at index, with the given stretch factor.

See also addWidget().

bool QStatusBar::isSizeGripEnabled() const

Returns the size grip property, false by default. It has no effect.

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

This signal is emitted when the message changes to message, which is empty when it is cleared.

[override] QSize QStatusBar::minimumSizeHint() const

Reimplements QWidget::minimumSizeHint().

[override, protected] void QStatusBar::paintEvent(QPaintEvent *event)

Reimplements QWidget::paintEvent().

void QStatusBar::removeWidget(QWidget *widget)

Removes widget from the status bar. It is not deleted, and is hidden; it stays a child.

See also addWidget().

[override, protected] void QStatusBar::resizeEvent(QResizeEvent *event)

Reimplements QWidget::resizeEvent().

void QStatusBar::setSizeGripEnabled(bool enabled)

Sets the size grip property to enabled. It has no effect.

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

Shows text in the status bar in place of the widgets on the left. If timeout is more than 0, the message goes away after that many milliseconds; otherwise it stays until clearMessage() or another message. Emits messageChanged().

See also clearMessage().

[override] QSize QStatusBar::sizeHint() const

Reimplements QWidget::sizeHint().

[override, protected] void QStatusBar::timerEvent(QTimerEvent *event)

Reimplements QWidget::timerEvent().