<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!-- /tmp/qt-4.2.1-harald-1161357942206/qt-x11-opensource-src-4.2.1/src/gui/widgets/qstatusbar.cpp --> <head> <title>Qt 4.2: QStatusBar Class Reference</title> <link href="classic.css" rel="stylesheet" type="text/css" /> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td> <td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="mainclasses.html"><font color="#004faf">Main Classes</font></a> · <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td> <td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">QStatusBar Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1> <p>The QStatusBar class provides a horizontal bar suitable for presenting status information. <a href="#details">More...</a></p> <pre> #include <QStatusBar></pre><p>Inherits <a href="qwidget.html">QWidget</a>.</p> <ul> <li><a href="qstatusbar-members.html">List of all members, including inherited members</a></li> <li><a href="qstatusbar-qt3.html">Qt 3 support members</a></li> </ul> <a name="properties"></a> <h3>Properties</h3> <ul> <li><div class="fn"/><b><a href="qstatusbar.html#sizeGripEnabled-prop">sizeGripEnabled</a></b> : bool</li> </ul> <ul> <li><div class="fn"/>55 properties inherited from <a href="qwidget.html#properties">QWidget</a></li> <li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li> </ul> <a name="public-functions"></a> <h3>Public Functions</h3> <ul> <li><div class="fn"/><b><a href="qstatusbar.html#QStatusBar">QStatusBar</a></b> ( QWidget * <i>parent</i> = 0 )</li> <li><div class="fn"/>virtual <b><a href="qstatusbar.html#dtor.QStatusBar">~QStatusBar</a></b> ()</li> <li><div class="fn"/>void <b><a href="qstatusbar.html#addPermanentWidget">addPermanentWidget</a></b> ( QWidget * <i>widget</i>, int <i>stretch</i> = 0 )</li> <li><div class="fn"/>void <b><a href="qstatusbar.html#addWidget">addWidget</a></b> ( QWidget * <i>widget</i>, int <i>stretch</i> = 0 )</li> <li><div class="fn"/>QString <b><a href="qstatusbar.html#currentMessage">currentMessage</a></b> () const</li> <li><div class="fn"/>int <b><a href="qstatusbar.html#insertPermanentWidget">insertPermanentWidget</a></b> ( int <i>index</i>, QWidget * <i>widget</i>, int <i>stretch</i> = 0 )</li> <li><div class="fn"/>int <b><a href="qstatusbar.html#insertWidget">insertWidget</a></b> ( int <i>index</i>, QWidget * <i>widget</i>, int <i>stretch</i> = 0 )</li> <li><div class="fn"/>bool <b><a href="qstatusbar.html#sizeGripEnabled-prop">isSizeGripEnabled</a></b> () const</li> <li><div class="fn"/>void <b><a href="qstatusbar.html#removeWidget">removeWidget</a></b> ( QWidget * <i>widget</i> )</li> <li><div class="fn"/>void <b><a href="qstatusbar.html#sizeGripEnabled-prop">setSizeGripEnabled</a></b> ( bool )</li> </ul> <ul> <li><div class="fn"/>195 public functions inherited from <a href="qwidget.html#public-functions">QWidget</a></li> <li><div class="fn"/>29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li> <li><div class="fn"/>12 public functions inherited from <a href="qpaintdevice.html#public-functions">QPaintDevice</a></li> </ul> <a name="public-slots"></a> <h3>Public Slots</h3> <ul> <li><div class="fn"/>void <b><a href="qstatusbar.html#clearMessage">clearMessage</a></b> ()</li> <li><div class="fn"/>void <b><a href="qstatusbar.html#showMessage">showMessage</a></b> ( const QString & <i>message</i>, int <i>timeout</i> = 0 )</li> </ul> <ul> <li><div class="fn"/>19 public slots inherited from <a href="qwidget.html#public-slots">QWidget</a></li> <li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li> </ul> <a name="signals"></a> <h3>Signals</h3> <ul> <li><div class="fn"/>void <b><a href="qstatusbar.html#messageChanged">messageChanged</a></b> ( const QString & <i>message</i> )</li> </ul> <ul> <li><div class="fn"/>1 signal inherited from <a href="qwidget.html#signals">QWidget</a></li> <li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li> </ul> <a name="protected-functions"></a> <h3>Protected Functions</h3> <ul> <li><div class="fn"/>void <b><a href="qstatusbar.html#hideOrShow">hideOrShow</a></b> ()</li> <li><div class="fn"/>void <b><a href="qstatusbar.html#reformat">reformat</a></b> ()</li> </ul> <ul> <li><div class="fn"/>38 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li> <li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li> <li><div class="fn"/>1 protected function inherited from <a href="qpaintdevice.html#protected-functions">QPaintDevice</a></li> </ul> <h3>Additional Inherited Members</h3> <ul> <li><div class="fn"/>4 static public members inherited from <a href="qwidget.html#static-public-members">QWidget</a></li> <li><div class="fn"/>5 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li> <li><div class="fn"/>1 protected slot inherited from <a href="qwidget.html#protected-slots">QWidget</a></li> </ul> <a name="details"></a> <hr /> <h2>Detailed Description</h2> <p>The QStatusBar class provides a horizontal bar suitable for presenting status information.</p> <p>Each status indicator falls into one of three categories:</p> <ul> <li><i>Temporary</i> - briefly occupies most of the status bar. Used to explain tool tip texts or menu entries, for example.</li> <li><i>Normal</i> - 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.</li> <li><i>Permanent</i> - is never hidden. Used for important mode indications, for example, some applications put a Caps Lock indicator in the status bar.</li> </ul> <p>QStatusBar lets you display all three types of indicators.</p> <p>Typically, a request for the status bar functionality occurs in relation to a <a href="qmainwindow.html">QMainWindow</a> object. <a href="qmainwindow.html">QMainWindow</a> provides a main application window, with a menu bar, tool bars, dock widgets <i>and</i> a status bar around a large central widget. The status bar can be retrieved using the <a href="qmainwindow.html#statusBar">QMainWindow::statusBar</a>() function, and replaced using the <a href="qmainwindow.html#setStatusBar">QMainWindow::setStatusBar</a>() function.</p> <p>Use the <a href="qstatusbar.html#showMessage">showMessage</a>() slot to display a <i>temporary</i> message:</p> <pre> void MainWindow::createStatusBar() { statusBar()->showMessage(tr("Ready")); }</pre> <p>To remove a temporary message, use the <a href="qstatusbar.html#clearMessage">clearMessage</a>() slot, or set a time limit when calling <a href="qstatusbar.html#showMessage">showMessage</a>(). For example:</p> <pre> 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); }</pre> <p>Use the <a href="qstatusbar.html#currentMessage">currentMessage</a>() function to retrieve the temporary message currently shown. The QStatusBar class also provide the <a href="qstatusbar.html#messageChanged">messageChanged</a>() signal which is emitted whenever the temporary status message changes.</p> <p><i>Normal</i> and <i>Permanent</i> messages are displayed by creating a small widget (<a href="qlabel.html">QLabel</a>, <a href="qprogressbar.html">QProgressBar</a> or even <a href="qtoolbutton.html">QToolButton</a>) and then adding it to the status bar using the <a href="qstatusbar.html#addWidget">addWidget</a>() or the <a href="qstatusbar.html#addPermanentWidget">addPermanentWidget</a>() function. Use the <a href="qstatusbar.html#removeWidget">removeWidget</a>() function to remove such messages from the status bar.</p> <pre> statusBar()->addWidget(new MyReadWriteIndication);</pre> <p>By default QStatusBar provides a <a href="qsizegrip.html">QSizeGrip</a> in the lower-right corner. You can disable it using the <a href="qstatusbar.html#sizeGripEnabled-prop">setSizeGripEnabled</a>() function. Use the <a href="qstatusbar.html#sizeGripEnabled-prop">isSizeGripEnabled</a>() function to determine the current status of the size grip.</p> <p align="center"><img src="images/plastique-statusbar.png" alt="A status bar shown in the Plastique widget style" /></p><p>See also <a href="qmainwindow.html">QMainWindow</a>, <a href="qstatustipevent.html">QStatusTipEvent</a>, <a href="guibooks.html#fowler">GUI Design Handbook: Status Bar</a>, and <a href="mainwindows-application.html">Application Example</a>.</p> <hr /> <h2>Property Documentation</h2> <h3 class="fn"><a name="sizeGripEnabled-prop"></a>sizeGripEnabled : bool</h3> <p>This property holds whether the QSizeGrip in the bottom-right corner of the status bar is enabled.</p> <p>The size grip is enabled by default.</p> <p>Access functions:</p> <ul> <li><div class="fn"/><b>bool isSizeGripEnabled () const</b></li> <li><div class="fn"/><b>void setSizeGripEnabled ( bool )</b></li> </ul> <hr /> <h2>Member Function Documentation</h2> <h3 class="fn"><a name="QStatusBar"></a>QStatusBar::QStatusBar ( <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0 )</h3> <p>Constructs a status bar with a size grip and the given <i>parent</i>.</p> <p>See also <a href="qstatusbar.html#sizeGripEnabled-prop">setSizeGripEnabled</a>().</p> <h3 class="fn"><a name="dtor.QStatusBar"></a>QStatusBar::~QStatusBar () <tt> [virtual]</tt></h3> <p>Destroys this status bar and frees any allocated resources and child widgets.</p> <h3 class="fn"><a name="addPermanentWidget"></a>void QStatusBar::addPermanentWidget ( <a href="qwidget.html">QWidget</a> * <i>widget</i>, int <i>stretch</i> = 0 )</h3> <p>Adds the given <i>widget</i> permanently to this status bar, reparenting the widget if it isn't already a child of this <a href="qstatusbar.html">QStatusBar</a> object. The <i>stretch</i> parameter is used to compute a suitable size for the given <i>widget</i> as the status bar grows and shrinks. The default stretch factor is 0, i.e giving the widget a minimum of space.</p> <p>Permanently means that the widget may not be obscured by temporary messages. It is is located at the far right of the status bar.</p> <p>See also <a href="qstatusbar.html#insertPermanentWidget">insertPermanentWidget</a>(), <a href="qstatusbar.html#removeWidget">removeWidget</a>(), and <a href="qstatusbar.html#addWidget">addWidget</a>().</p> <h3 class="fn"><a name="addWidget"></a>void QStatusBar::addWidget ( <a href="qwidget.html">QWidget</a> * <i>widget</i>, int <i>stretch</i> = 0 )</h3> <p>Adds the given <i>widget</i> to this status bar, reparenting the widget if it isn't already a child of this <a href="qstatusbar.html">QStatusBar</a> object. The <i>stretch</i> parameter is used to compute a suitable size for the given <i>widget</i> as the status bar grows and shrinks. The default stretch factor is 0, i.e giving the widget a minimum of space.</p> <p>The widget is located to the far left of the first permanent widget (see <a href="qstatusbar.html#addPermanentWidget">addPermanentWidget</a>()) and may be obscured by temporary messages.</p> <p>See also <a href="qstatusbar.html#insertWidget">insertWidget</a>(), <a href="qstatusbar.html#removeWidget">removeWidget</a>(), and <a href="qstatusbar.html#addPermanentWidget">addPermanentWidget</a>().</p> <h3 class="fn"><a name="clearMessage"></a>void QStatusBar::clearMessage () <tt> [slot]</tt></h3> <p>Removes any temporary message being shown.</p> <p>See also <a href="qstatusbar.html#currentMessage">currentMessage</a>(), <a href="qstatusbar.html#showMessage">showMessage</a>(), and <a href="qstatusbar.html#removeWidget">removeWidget</a>().</p> <h3 class="fn"><a name="currentMessage"></a><a href="qstring.html">QString</a> QStatusBar::currentMessage () const</h3> <p>Returns the temporary message currently shown, or an empty string if there is no such message.</p> <p>See also <a href="qstatusbar.html#showMessage">showMessage</a>().</p> <h3 class="fn"><a name="hideOrShow"></a>void QStatusBar::hideOrShow () <tt> [protected]</tt></h3> <p>Ensures that the right widgets are visible.</p> <p>Used by the <a href="qstatusbar.html#showMessage">showMessage</a>() and <a href="qstatusbar.html#clearMessage">clearMessage</a>() functions.</p> <h3 class="fn"><a name="insertPermanentWidget"></a>int QStatusBar::insertPermanentWidget ( int <i>index</i>, <a href="qwidget.html">QWidget</a> * <i>widget</i>, int <i>stretch</i> = 0 )</h3> <p>Inserts the given <i>widget</i> at the given <i>index</i> permanently to this status bar, reparenting the widget if it isn't already a child of this <a href="qstatusbar.html">QStatusBar</a> object. If <i>index</i> is out of range, the widget is appended (in which case it is the actual index of the widget that is returned).</p> <p>The <i>stretch</i> parameter is used to compute a suitable size for the given <i>widget</i> as the status bar grows and shrinks. The default stretch factor is 0, i.e giving the widget a minimum of space.</p> <p>Permanently means that the widget may not be obscured by temporary messages. It is is located at the far right of the status bar.</p> <p>This function was introduced in Qt 4.2.</p> <p>See also <a href="qstatusbar.html#addPermanentWidget">addPermanentWidget</a>(), <a href="qstatusbar.html#removeWidget">removeWidget</a>(), and <a href="qstatusbar.html#addWidget">addWidget</a>().</p> <h3 class="fn"><a name="insertWidget"></a>int QStatusBar::insertWidget ( int <i>index</i>, <a href="qwidget.html">QWidget</a> * <i>widget</i>, int <i>stretch</i> = 0 )</h3> <p>Inserts the given <i>widget</i> at the given <i>index</i> to this status bar, reparenting the widget if it isn't already a child of this <a href="qstatusbar.html">QStatusBar</a> object. If <i>index</i> is out of range, the widget is appended (in which case it is the actual index of the widget that is returned).</p> <p>The <i>stretch</i> parameter is used to compute a suitable size for the given <i>widget</i> as the status bar grows and shrinks. The default stretch factor is 0, i.e giving the widget a minimum of space.</p> <p>The widget is located to the far left of the first permanent widget (see <a href="qstatusbar.html#addPermanentWidget">addPermanentWidget</a>()) and may be obscured by temporary messages.</p> <p>This function was introduced in Qt 4.2.</p> <p>See also <a href="qstatusbar.html#addWidget">addWidget</a>(), <a href="qstatusbar.html#removeWidget">removeWidget</a>(), and <a href="qstatusbar.html#addPermanentWidget">addPermanentWidget</a>().</p> <h3 class="fn"><a name="messageChanged"></a>void QStatusBar::messageChanged ( const <a href="qstring.html">QString</a> & <i>message</i> ) <tt> [signal]</tt></h3> <p>This signal is emitted whenever the temporary status message changes. The new temporary message is passed in the <i>message</i> parameter which is a null-string when the message has been removed.</p> <p>See also <a href="qstatusbar.html#showMessage">showMessage</a>() and <a href="qstatusbar.html#clearMessage">clearMessage</a>().</p> <h3 class="fn"><a name="reformat"></a>void QStatusBar::reformat () <tt> [protected]</tt></h3> <p>Changes the status bar's appearance to account for item changes.</p> <p>Special subclasses may need this function, but geometry management will usually take care of any necessary rearrangements.</p> <h3 class="fn"><a name="removeWidget"></a>void QStatusBar::removeWidget ( <a href="qwidget.html">QWidget</a> * <i>widget</i> )</h3> <p>Removes the specifed <i>widget</i> from the status bar (without deleting it).</p> <p>See also <a href="qstatusbar.html#addWidget">addWidget</a>(), <a href="qstatusbar.html#addPermanentWidget">addPermanentWidget</a>(), and <a href="qstatusbar.html#clearMessage">clearMessage</a>().</p> <h3 class="fn"><a name="showMessage"></a>void QStatusBar::showMessage ( const <a href="qstring.html">QString</a> & <i>message</i>, int <i>timeout</i> = 0 ) <tt> [slot]</tt></h3> <p>Hides the normal status indications and displays the given <i>message</i> for the specified <i>timeout</i> milli-seconds (if non-zero), or until <a href="qstatusbar.html#clearMessage">clearMessage</a>() or another showMessage() is called, whichever occurs first.</p> <p>See also <a href="qstatusbar.html#messageChanged">messageChanged</a>(), <a href="qstatusbar.html#currentMessage">currentMessage</a>(), and <a href="qstatusbar.html#clearMessage">clearMessage</a>().</p> <hr /> <h2>Member Function Documentation</h2> <h3 class="fn"><a name="QStatusBar-2"></a>QStatusBar::QStatusBar ( <a href="qwidget.html">QWidget</a> * <i>parent</i>, const char * <i>name</i> )</h3> <p>Constructs a status bar with a size grip and the given <i>parent</i> and object <i>name</i>.</p> <p>Use the <a href="qstatusbar.html#QStatusBar">QStatusBar</a>() constructor and the <a href="qobject.html#objectName-prop">QObject::setObjectName</a>() function instead.</p> <p>For example, if you have code like</p> <pre><font color="#404040"> QStatusBar *myStatusBar = new QStatusBar(parent, name);</font></pre> <p>you can rewrite it as</p> <pre> QStatusBar *myStatusBar = new QStatusBar(parent); myStatusBar->setObjectName(name);</pre> <h3 class="fn"><a name="addWidget-2"></a>void QStatusBar::addWidget ( <a href="qwidget.html">QWidget</a> * <i>widget</i>, int <i>stretch</i>, bool <i>permanent</i> )</h3> <p>This is an overloaded member function, provided for convenience.</p> <p>Use <a href="qstatusbar.html#addWidget">addWidget</a>() or <a href="qstatusbar.html#addPermanentWidget">addPermanentWidget</a>() instead, depending on the value of the <i>permanent</i> parameter.</p> <p>For example, if you have code like</p> <pre><font color="#404040"> QStatusBar *myStatusBar; myStatusBar->addWidget(widget, stretch, permanent); // permanent == true</font></pre> <p>you can rewrite it as</p> <pre> QStatusBar *myStatusBar; myStatusBar->addPermanentWidget(widget, stretch);</pre> <h3 class="fn"><a name="clear"></a>void QStatusBar::clear () <tt> [slot]</tt></h3> <p>Use the <a href="qstatusbar.html#clearMessage">clearMessage</a>() function instead.</p> <h3 class="fn"><a name="message"></a>void QStatusBar::message ( const <a href="qstring.html">QString</a> & <i>message</i>, int <i>timeout</i> = 0 ) <tt> [slot]</tt></h3> <p>Use the <a href="qstatusbar.html#showMessage">showMessage</a>() function instead.</p> <p /><address><hr /><div align="center"> <table width="100%" cellspacing="0" border="0"><tr class="address"> <td width="30%">Copyright © 2006 <a href="trolltech.html">Trolltech</a></td> <td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td> <td width="30%" align="right"><div align="right">Qt 4.2.1</div></td> </tr></table></div></address></body> </html>