Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QStatusBar Class

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

Header:#include <QStatusBar>
Inherits:QWidget

Properties

Public Functions

QStatusBar(QWidget * parent = 0)
virtual~QStatusBar()
voidaddPermanentWidget(QWidget * widget, int stretch = 0)
voidaddWidget(QWidget * widget, int stretch = 0)
QStringcurrentMessage() const
intinsertPermanentWidget(int index, QWidget * widget, int stretch = 0)
intinsertWidget(int index, QWidget * widget, int stretch = 0)
boolisSizeGripEnabled() const
voidremoveWidget(QWidget * widget)
voidsetSizeGripEnabled(bool)

Public Slots

voidclearMessage()
voidshowMessage(const QString & message, int timeout = 0)
  • 19 public slots inherited fromQWidget
  • 1 public slot inherited fromQObject

Signals

voidmessageChanged(const QString & message)

Protected Functions

voidhideOrShow()
voidreformat()

Reimplemented Protected Functions

virtual boolevent(QEvent * e)
virtual voidpaintEvent(QPaintEvent * event)
virtual voidresizeEvent(QResizeEvent * e)
virtual voidshowEvent(QShowEvent *)
  • 37 protected functions inherited fromQWidget
  • 8 protected functions inherited fromQObject
  • 1 protected function inherited fromQPaintDevice

Additional Inherited Members

  • 4 static public members inherited fromQWidget
  • 7 static public members inherited fromQObject
  • 1 protected slot inherited fromQWidget

Detailed Description

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

A status bar shown in the Plastique widget style

See alsoQMainWindow,QStatusTipEvent,GUI Design Handbook: Status Bar, andApplication Example.

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:

boolisSizeGripEnabled() const
voidsetSizeGripEnabled(bool)

Member Function Documentation

QStatusBar::QStatusBar(QWidget * parent = 0)

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.

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

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().

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

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().

QString QStatusBar::currentMessage() const

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.

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

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().

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

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.

void QStatusBar::removeWidget(QWidget * widget)

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.


[8]ページ先頭

©2009-2025 Movatter.jp