Qt:Документация 4.3.2/qstatusbar

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

[править] QStatusBar Class Reference
[модуль QtGui ]

The QStatusBar class provides a horizontal bar suitable for presenting status information. Далее...

 #include <QStatusBar>

Наследует QWidget.

[править] Свойства

  • 56 свойств, унаследованных от QWidget
  • 1 свойство, унаследованное от QObject

[править] Открытые функции

  • 201 свойство, унаследованное от QWidget
  • 29 открытых функций, унаследованных от QObject
  • 12 открытых функций, унаследованных от QPaintDevice

[править] Открытые слоты

  • 19 открытых слотов, унаследованных от QWidget
  • 1 открытый слот, унаследованный от QObject

[править] Сигналы

  • 1 сигнал, унаследованный от QWidget
  • 1 сигнал, унаследованный от QObject

[править] Защищенные функции

  • 38 защищенных функций, унаследованных от QWidget
  • 7 защищенных функций, унаследованных от QObject
  • 1 защищенная функция, унаследованных от QPaintDevice

[править] Дополнительные унаследованные члены

  • 4 статических открытых члена, унаследованных от QWidget
  • 5 статических открытых членов, унаследованных от QObject
  • 1 защищенный слот, унаследованый от QWidget

[править] Подробное описание

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(). Пример:

 void MainWindow::print()
 {
     QTextDocument *document = textEdit->document();
     QPrinter printer;
 
     QPrintDialog *dlg = new QPrintDialog(&amp;printer, this);
     if (dlg->exec() != QDialog::Accepted)
         return;
 
     document->print(&amp;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.

Файл:Plastique-statusbar.png

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


[править] Описание cвойств

[править]
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.

Функции доступа:

  • bool isSizeGripEnabled () const
  • void setSizeGripEnabled ( bool )

[править] Описание функций-членов

[править]
QStatusBar::QStatusBar ( QWidget * parent = 0 )

Constructs a status bar with a size grip and the given parent.

See also setSizeGripEnabled().

[править]
QStatusBar::~QStatusBar () [virtual]

Destroys this status bar and frees any allocated resources and child widgets.

[править]
void QStatusBar::addPermanentWidget ( QWidget * widget, int stretch = 0 )

Adds the given widget permanently to this status bar, reparenting the widget if it isn't already a child of this QStatusBar object. The stretch parameter is used to compute a suitable size for the given widget 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 also insertPermanentWidget(), removeWidget(), and addWidget().

[править]
void QStatusBar::addWidget ( QWidget * widget, int stretch = 0 )

Adds the given widget to this status bar, reparenting the widget if it isn't already a child of this QStatusBar object. The stretch parameter is used to compute a suitable size for the given widget 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 (see addPermanentWidget()) and may be obscured by temporary messages.

See also insertWidget(), removeWidget(), and addPermanentWidget().

[править]
void QStatusBar::clearMessage () [slot]

Removes any temporary message being shown.

See also currentMessage(), showMessage(), and removeWidget().

[править]
QString QStatusBar::currentMessage () const

Returns the temporary message currently shown, or an empty string if there is no such message.

See also showMessage().

[править]
void QStatusBar::hideOrShow () [protected]

Ensures that the right widgets are visible.

Used by the showMessage() and clearMessage() functions.

[править]
int QStatusBar::insertPermanentWidget ( int index, QWidget * widget, int stretch = 0 )

Inserts the given widget at the given index permanently to this status bar, reparenting the widget if it isn't already a child of this QStatusBar object. If index is out of range, the widget is appended (in which case it is the actual index of the widget that is returned).

The stretch parameter is used to compute a suitable size for the given widget 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.

Эта функция была введена в Qt 4.2.

See also addPermanentWidget(), removeWidget(), and addWidget().

[править]
int QStatusBar::insertWidget ( int index, QWidget * widget, int stretch = 0 )

Inserts the given widget at the given index to this status bar, reparenting the widget if it isn't already a child of this QStatusBar object. If index is out of range, the widget is appended (in which case it is the actual index of the widget that is returned).

The stretch parameter is used to compute a suitable size for the given widget 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 (see addPermanentWidget()) and may be obscured by temporary messages.

Эта функция была введена в Qt 4.2.

See also addWidget(), removeWidget(), and addPermanentWidget().

[править]
void QStatusBar::messageChanged ( const QString & message ) [signal]

This signal is emitted whenever the temporary status message changes. The new temporary message is passed in the message parameter which is a null-string when the message has been removed.

See also showMessage() and clearMessage().

[править]
void QStatusBar::reformat () [protected]

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 specified widget from the status bar (without deleting it).

See also addWidget(), addPermanentWidget(), and clearMessage().

[править]
void QStatusBar::showMessage ( const QString & message, int timeout = 0 ) [slot]

Hides the normal status indications and displays the given message for the specified timeout milli-seconds (if non-zero), or until clearMessage() or another showMessage() is called, whichever occurs first.

See also messageChanged(), currentMessage(), and clearMessage().



Copyright © 2007 Trolltech Trademarks
Qt 4.3.2