| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head>
|
|---|
| 2 | <title>Qt Toolkit - QLabel Class</title><style type="text/css"><!--
|
|---|
| 3 | h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
|
|---|
| 4 | a:link { color: #004faf; text-decoration: none }
|
|---|
| 5 | a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
|
|---|
| 6 | --></style>
|
|---|
| 7 | </head><body bgcolor="#ffffff">
|
|---|
| 8 |
|
|---|
| 9 | <h1 align=center>QLabel Class Reference</h1><br clear="all">
|
|---|
| 10 | <p>
|
|---|
| 11 | The QLabel widget provides a static information display
|
|---|
| 12 | <a href="#details">More...</a>
|
|---|
| 13 | <p>
|
|---|
| 14 | <code>#include <<a href="qlabel-h.html">qlabel.h</a>></code>
|
|---|
| 15 | <p>
|
|---|
| 16 | Inherits <a href="qframe.html">QFrame</a>.
|
|---|
| 17 | <p><a href="qlabel-members.html">List of all member functions.</a>
|
|---|
| 18 | <h2>Public Members</h2>
|
|---|
| 19 | <ul>
|
|---|
| 20 | <li><div class="fn"><a href="#39107d"><b>QLabel</b></a> ( QWidget * parent, const char * name=0, WFlags f=0 ) </div>
|
|---|
| 21 | <li><div class="fn"><a href="#2bafbb"><b>QLabel</b></a> ( const QString & text, QWidget * parent, const char * name=0, WFlags f=0 ) </div>
|
|---|
| 22 | <li><div class="fn"><a href="#5514c7"><b>QLabel</b></a> ( QWidget * buddy, const QString &, QWidget * parent, const char * name=0, WFlags f=0 ) </div>
|
|---|
| 23 | <li><div class="fn"><a href="#9958af"><b>~QLabel</b></a> () </div>
|
|---|
| 24 | <li><div class="fn">QString <a href="#72cf09"><b>text</b></a> () const</div>
|
|---|
| 25 | <li><div class="fn">QPixmap* <a href="#101ecb"><b>pixmap</b></a> () const</div>
|
|---|
| 26 | <li><div class="fn">QMovie* <a href="#7dcdfe"><b>movie</b></a> () const</div>
|
|---|
| 27 | <li><div class="fn">TextFormat <a href="#0b92ed"><b>textFormat</b></a> () const</div>
|
|---|
| 28 | <li><div class="fn">void <a href="#5de3f9"><b>setTextFormat</b></a> ( TextFormat ) </div>
|
|---|
| 29 | <li><div class="fn">int <a href="#2fcaa3"><b>alignment</b></a> () const</div>
|
|---|
| 30 | <li><div class="fn">virtual void <a href="#1f406e"><b>setAlignment</b></a> ( int ) </div>
|
|---|
| 31 | <li><div class="fn">int <a href="#e3c907"><b>indent</b></a> () const</div>
|
|---|
| 32 | <li><div class="fn">void <a href="#ed9b8b"><b>setIndent</b></a> ( int ) </div>
|
|---|
| 33 | <li><div class="fn">bool autoResize () const <em>(obsolete)</em></div>
|
|---|
| 34 | <li><div class="fn">virtual void setAutoResize ( bool ) <em>(obsolete)</em></div>
|
|---|
| 35 | <li><div class="fn">bool <a href="#7e1f73"><b>hasScaledContents</b></a> () const</div>
|
|---|
| 36 | <li><div class="fn">void <a href="#e9e3cf"><b>setScaledContents</b></a> ( bool ) </div>
|
|---|
| 37 | <li><div class="fn">virtual void <a href="#191701"><b>setBuddy</b></a> ( QWidget * ) </div>
|
|---|
| 38 | <li><div class="fn">QWidget* <a href="#123954"><b>buddy</b></a> () const</div>
|
|---|
| 39 | </ul>
|
|---|
| 40 | <h2>Public Slots</h2>
|
|---|
| 41 | <ul>
|
|---|
| 42 | <li><div class="fn">virtual void <a href="#dffb43"><b>setText</b></a> ( const QString & ) </div>
|
|---|
| 43 | <li><div class="fn">virtual void <a href="#f3f301"><b>setPixmap</b></a> ( const QPixmap & ) </div>
|
|---|
| 44 | <li><div class="fn">virtual void <a href="#60de9f"><b>setMovie</b></a> ( const QMovie & ) </div>
|
|---|
| 45 | <li><div class="fn">virtual void <a href="#301e3c"><b>setNum</b></a> ( int ) </div>
|
|---|
| 46 | <li><div class="fn">virtual void <a href="#1a8f6a"><b>setNum</b></a> ( double ) </div>
|
|---|
| 47 | <li><div class="fn">void <a href="#be73f3"><b>clear</b></a> () </div>
|
|---|
| 48 | </ul>
|
|---|
| 49 | <h2>Protected Members</h2>
|
|---|
| 50 | <ul>
|
|---|
| 51 | <li><div class="fn">virtual void <a href="#fac264"><b>drawContents</b></a> ( QPainter * ) </div>
|
|---|
| 52 | <li><div class="fn">virtual void <a href="#479dd2"><b>drawContentsMask</b></a> ( QPainter * ) </div>
|
|---|
| 53 | </ul>
|
|---|
| 54 | <h2>Properties</h2>
|
|---|
| 55 | <table border=1 cellpadding=3 cellspacing=0>
|
|---|
| 56 | <tr><th>Type<th>Name<th>READ<th>WRITE<th>Options
|
|---|
| 57 | <tr><td>QString<td>text<td>text<td>setText<td>
|
|---|
| 58 | <tr><td>TextFormat<td>textFormat<td>textFormat<td>setTextFormat<td>
|
|---|
| 59 | <tr><td>QPixmap<td>pixmap<td>pixmap<td>setPixmap<td>
|
|---|
| 60 | <tr><td>bool<td>scaledContents<td>hasScaledContents<td>setScaledContents<td>
|
|---|
| 61 | <tr><td>Alignment<td>alignment<td>alignment<td>setAlignment<td>
|
|---|
| 62 | <tr><td>int<td>indent<td>indent<td>setIndent<td>
|
|---|
| 63 | </table>
|
|---|
| 64 | <p>
|
|---|
| 65 | <hr><h2><a name="details"></a>Detailed Description</h2>
|
|---|
| 66 | The QLabel widget provides a static information display
|
|---|
| 67 | <p>
|
|---|
| 68 | QLabel is used for displaying information in the form of text or
|
|---|
| 69 | image to the user. No user interaction functionality is
|
|---|
| 70 | provided. The visual appearance of the label can be configured in
|
|---|
| 71 | various ways, and it can be used for specifying a focus accelerator
|
|---|
| 72 | key for another widget.
|
|---|
| 73 | <p>A QLabel can contain any of the following content types:
|
|---|
| 74 | <ul>
|
|---|
| 75 | <li> A plain text: set by passing a <a href="qstring.html">QString</a> to <a href="#dffb43">setText</a>().
|
|---|
| 76 | <li> A rich text: set by passing a QString that contains a rich text to setText().
|
|---|
| 77 | <li> A pixmap: set by passing a <a href="qpixmap.html">QPixmap</a> to <a href="#f3f301">setPixmap</a>().
|
|---|
| 78 | <li> A movie: set by passing a <a href="qmovie.html">QMovie</a> to <a href="#60de9f">setMovie</a>().
|
|---|
| 79 | <li> A number: set by passing an <em>int</em> or a <em>double</em> to <a href="#1a8f6a">setNum</a>(), which converts the number to plain text.
|
|---|
| 80 | <li> Nothing: The same as an empty plain text. This is the default. Set by <a href="#be73f3">clear</a>().
|
|---|
| 81 | </ul>
|
|---|
| 82 | <p>When the content is changed using any of these functions, any
|
|---|
| 83 | previous content is cleared.
|
|---|
| 84 | <p>The look of a QLabel can be tuned in several ways. All the settings
|
|---|
| 85 | of <a href="qframe.html">QFrame</a> are available for specifying a widget frame. The
|
|---|
| 86 | positioning of the content within the QLabel widget area can be
|
|---|
| 87 | tuned with <a href="#1f406e">setAlignment</a>() and <a href="#ed9b8b">setIndent</a>(). For example, this code
|
|---|
| 88 | sets up a sunken panel with a two-line text in the bottom right
|
|---|
| 89 | corner (both lines being flush with the right side of the label):
|
|---|
| 90 | <p><pre> <a href="qlabel.html">QLabel</a> *label = new <a href="qlabel.html">QLabel</a>;
|
|---|
| 91 | label-><a href="qframe.html#c0d758">setFrameStyle</a>( QFrame::Panel | QFrame::Sunken );
|
|---|
| 92 | label-><a href="#dffb43">setText</a>( "first line\nsecond line" );
|
|---|
| 93 | label-><a href="#1f406e">setAlignment</a>( AlignBottom | AlignRight );
|
|---|
| 94 | </pre>
|
|---|
| 95 | <p>A QLabel is often used as a label for another, interactive
|
|---|
| 96 | widget. For this use, QLabel provides a handy mechanism for adding
|
|---|
| 97 | an accelerator key (see <a href="qaccel.html">QAccel</a>) that will set the keyboard focus to
|
|---|
| 98 | the other widget (called the QLabel's "buddy"). Example:
|
|---|
| 99 | <p><pre> <a href="qlineedit.html">QLineEdit</a>* phoneEdit = new <a href="qlineedit.html">QLineEdit</a>( this, "phoneEdit" );
|
|---|
| 100 | <a href="qlabel.html">QLabel</a>* phoneLabel = new <a href="qlabel.html">QLabel</a>( phoneEdit, "&Phone:", this, "phoneLabel" );
|
|---|
| 101 | </pre>
|
|---|
| 102 | <p>In this example, keyboard focus is transferred to the label's buddy
|
|---|
| 103 | (the <a href="qlineedit.html">QLineEdit</a>) when the user presses <dfn>Alt-P.</dfn> You can also
|
|---|
| 104 | use the <a href="#191701">setBuddy</a>() function to accomplish the same.
|
|---|
| 105 | <p>
|
|---|
| 106 | <p>See also <a href="qlineedit.html">QLineEdit</a>, <a href="qtextview.html">QTextView</a>, <a href="qpixmap.html">QPixmap</a>, <a href="qmovie.html">QMovie</a> and <a href="guibooks.html#fowler">GUI Design Handbook: Label</a>
|
|---|
| 107 | <p>Examples:
|
|---|
| 108 | <a href="cursor-cursor-cpp.html#QLabel">cursor/cursor.cpp</a>
|
|---|
| 109 | <a href="layout-layout-cpp.html#QLabel">layout/layout.cpp</a>
|
|---|
| 110 | <a href="popup-popup-cpp.html#QLabel">popup/popup.cpp</a>
|
|---|
| 111 | <a href="menu-menu-cpp.html#QLabel">menu/menu.cpp</a>
|
|---|
| 112 | <a href="progress-progress-cpp.html#QLabel">progress/progress.cpp</a>
|
|---|
| 113 | <a href="qmag-qmag-cpp.html#QLabel">qmag/qmag.cpp</a>
|
|---|
| 114 | <a href="movies-main-cpp.html#QLabel">movies/main.cpp</a>
|
|---|
| 115 | <a href="customlayout-main-cpp.html#QLabel">customlayout/main.cpp</a>
|
|---|
| 116 |
|
|---|
| 117 | <hr><h2>Member Function Documentation</h2>
|
|---|
| 118 | <h3 class="fn"><a name="5514c7"></a>QLabel::QLabel ( <a href="qwidget.html">QWidget</a> * buddy, const <a href="qstring.html">QString</a> & text, <a href="qwidget.html">QWidget</a> * parent, const char * name=0, WFlags f=0 )</h3>
|
|---|
| 119 | <p>Constructs a label with a text and a buddy.
|
|---|
| 120 | <p>The <em>text</em> is set with <a href="#dffb43">setText</a>(). The <em>buddy</em> is set with <a href="#191701">setBuddy</a>().
|
|---|
| 121 | <p>The <em>parent, name</em> and <em>f</em> arguments are passed to the <a href="qframe.html">QFrame</a>
|
|---|
| 122 | constructor.
|
|---|
| 123 | <p>See also <a href="#dffb43">setText</a>(), <a href="#191701">setBuddy</a>(), <a href="#1f406e">setAlignment</a>(), <a href="qframe.html#c0d758">setFrameStyle</a>() and <a href="#ed9b8b">setIndent</a>().
|
|---|
| 124 | <h3 class="fn"><a name="39107d"></a>QLabel::QLabel ( <a href="qwidget.html">QWidget</a> * parent, const char * name=0, WFlags f=0 )</h3>
|
|---|
| 125 | <p>Constructs an empty label.
|
|---|
| 126 | <p>The <em>parent, name</em> and <em>f</em> arguments are passed to the <a href="qframe.html">QFrame</a>
|
|---|
| 127 | constructor.
|
|---|
| 128 | <p>See also <a href="#1f406e">setAlignment</a>(), <a href="qframe.html#c0d758">setFrameStyle</a>() and <a href="#ed9b8b">setIndent</a>().
|
|---|
| 129 | <h3 class="fn"><a name="2bafbb"></a>QLabel::QLabel ( const <a href="qstring.html">QString</a> & text, <a href="qwidget.html">QWidget</a> * parent, const char * name=0, WFlags f=0 )</h3>
|
|---|
| 130 | <p>Constructs a label with a text. The <em>text</em> is set with <a href="#dffb43">setText</a>().
|
|---|
| 131 | <p>The <em>parent, name</em> and <em>f</em> arguments are passed to the <a href="qframe.html">QFrame</a>
|
|---|
| 132 | constructor.
|
|---|
| 133 | <p>See also <a href="#dffb43">setText</a>(), <a href="#1f406e">setAlignment</a>(), <a href="qframe.html#c0d758">setFrameStyle</a>() and <a href="#ed9b8b">setIndent</a>().
|
|---|
| 134 | <h3 class="fn"><a name="9958af"></a>QLabel::~QLabel ()</h3>
|
|---|
| 135 | <p>Destructs the label.
|
|---|
| 136 | <h3 class="fn">int <a name="2fcaa3"></a>QLabel::alignment () const</h3>
|
|---|
| 137 | <p>Returns the alignment setting.
|
|---|
| 138 | <p>See also <a href="#1f406e">setAlignment</a>().
|
|---|
| 139 | <h3 class="fn">bool <a name="75b2a1"></a>QLabel::autoResize () const</h3>
|
|---|
| 140 | <p><b>This function is obsolete.</b> It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.<p>
|
|---|
| 141 | <p>Returns TRUE if auto-resizing is enabled, or FALSE if auto-resizing
|
|---|
| 142 | is disabled.
|
|---|
| 143 | <p>Auto-resizing is disabled by default.
|
|---|
| 144 | <p>See also <a href="#c0e104">setAutoResize</a>().
|
|---|
| 145 | <h3 class="fn"><a href="qwidget.html">QWidget</a> * <a name="123954"></a>QLabel::buddy () const</h3>
|
|---|
| 146 | <p>Returns the buddy of this label, or 0 if no buddy is currently set.
|
|---|
| 147 | <p>See also <a href="#191701">setBuddy</a>().
|
|---|
| 148 | <h3 class="fn">void <a name="be73f3"></a>QLabel::clear () <code>[slot]</code></h3>
|
|---|
| 149 | <p>Clears any label contents. Equivalent with <a href="#dffb43">setText</a>( "" ).
|
|---|
| 150 | <h3 class="fn">void <a name="fac264"></a>QLabel::drawContents ( <a href="qpainter.html">QPainter</a> * p ) <code>[virtual protected]</code></h3>
|
|---|
| 151 | <p>Draws the label contents using the painter <em>p.</em>
|
|---|
| 152 | <p>Reimplemented from <a href="qframe.html#99e687">QFrame.</a>
|
|---|
| 153 | <h3 class="fn">void <a name="479dd2"></a>QLabel::drawContentsMask ( <a href="qpainter.html">QPainter</a> * p ) <code>[virtual protected]</code></h3>
|
|---|
| 154 | <p>Draws the label contents mask using the painter <em>p.</em>
|
|---|
| 155 | Used only in transparent mode.
|
|---|
| 156 | <p>See also <a href="qwidget.html#c7a335">QWidget::setAutoMask</a>();.
|
|---|
| 157 | <p>Reimplemented from <a href="qframe.html#4cbf11">QFrame.</a>
|
|---|
| 158 | <h3 class="fn">void <a name="0435a2"></a>QLabel::fontChange ( const <a href="qfont.html">QFont</a> & ) <code>[virtual protected]</code></h3>
|
|---|
| 159 | <p>Reimplemented for internal reasons; the API is not affected.
|
|---|
| 160 | <p>Reimplemented from <a href="qwidget.html#570a8f">QWidget.</a>
|
|---|
| 161 | <h3 class="fn">bool <a name="7e1f73"></a>QLabel::hasScaledContents () const</h3>
|
|---|
| 162 | <p>Returns whether the label will scale its contents to fill all
|
|---|
| 163 | available space.
|
|---|
| 164 | <p>See also <a href="#e9e3cf">setScaledContents</a>().
|
|---|
| 165 | <h3 class="fn">int <a name="dae451"></a>QLabel::heightForWidth ( int w ) const <code>[virtual]</code></h3>
|
|---|
| 166 | <p>Reimplemented for internal reasons; the API is not affected.
|
|---|
| 167 | <p>Reimplemented from <a href="qwidget.html#2e8476">QWidget.</a>
|
|---|
| 168 | <h3 class="fn">int <a name="e3c907"></a>QLabel::indent () const</h3>
|
|---|
| 169 | <p>Returns the indent of the label.
|
|---|
| 170 | <p>See also <a href="#ed9b8b">setIndent</a>().
|
|---|
| 171 | <h3 class="fn"><a href="qsize.html">QSize</a> <a name="53c8c7"></a>QLabel::minimumSizeHint () const <code>[virtual]</code></h3>
|
|---|
| 172 | <p>Reimplemented for internal reasons; the API is not affected.
|
|---|
| 173 | <p>Reimplemented from <a href="qwidget.html#3f0fc2">QWidget.</a>
|
|---|
| 174 | <h3 class="fn"><a href="qmovie.html">QMovie</a>* <a name="7dcdfe"></a>QLabel::movie () const</h3>
|
|---|
| 175 | <p>If the label contains a movie, returns a pointer to it. Otherwise,
|
|---|
| 176 | returns 0.
|
|---|
| 177 | <p>See also <a href="#60de9f">setMovie</a>().
|
|---|
| 178 | <h3 class="fn"><a href="qpixmap.html">QPixmap</a> * <a name="101ecb"></a>QLabel::pixmap () const</h3>
|
|---|
| 179 | <p>If the label contains a pixmap, returns a pointer to it. Otherwise,
|
|---|
| 180 | returns 0.
|
|---|
| 181 | <p>See also <a href="#f3f301">setPixmap</a>().
|
|---|
| 182 | <h3 class="fn">void <a name="3cb6e7"></a>QLabel::resizeEvent ( <a href="qresizeevent.html">QResizeEvent</a> * e ) <code>[virtual protected]</code></h3>
|
|---|
| 183 | <p>Reimplemented for internal reasons; the API is not affected.
|
|---|
| 184 | <p>Reimplemented from <a href="qwidget.html#28c156">QWidget.</a>
|
|---|
| 185 | <h3 class="fn">void <a name="1f406e"></a>QLabel::setAlignment ( int alignment ) <code>[virtual]</code></h3>
|
|---|
| 186 | <p>Sets the alignment of the label contents.
|
|---|
| 187 | <p>The <em>alignment</em> must be a bitwise OR of <a href="qt.html#AlignmentFlags">Qt::AlignmentFlags</a>
|
|---|
| 188 | values. The <code>WordBreak, ExpandTabs, SingleLine</code> and <code>ShowPrefix</code> flags apply only if the label contains a plain text, and
|
|---|
| 189 | are otherwise ignored. The <code>DontClip</code> flag is always ignored.
|
|---|
| 190 | <p>If the label has a buddy, the <code>ShowPrefix</code> flag is forced to TRUE.
|
|---|
| 191 | <p>The default alignment is <code>AlignLeft | AlignVCenter |
|
|---|
| 192 | ExpandTabs</code> if the label doesn't have a buddy and
|
|---|
| 193 | <code>AlignLeft | AlignVCenter | ExpandTabs | ShowPrefix </code> if
|
|---|
| 194 | the label has a buddy.
|
|---|
| 195 | <p>See also <a href="qt.html#AlignmentFlags">Qt::AlignmentFlags</a>, <a href="#2fcaa3">alignment</a>(), <a href="#191701">setBuddy</a>() and <a href="#dffb43">setText</a>().
|
|---|
| 196 | <p>Examples:
|
|---|
| 197 | <a href="cursor-cursor-cpp.html#setAlignment">cursor/cursor.cpp</a>
|
|---|
| 198 | <a href="layout-layout-cpp.html#setAlignment">layout/layout.cpp</a>
|
|---|
| 199 | <a href="popup-popup-cpp.html#setAlignment">popup/popup.cpp</a>
|
|---|
| 200 | <a href="qmag-qmag-cpp.html#setAlignment">qmag/qmag.cpp</a>
|
|---|
| 201 | <a href="customlayout-main-cpp.html#setAlignment">customlayout/main.cpp</a>
|
|---|
| 202 | <h3 class="fn">void <a name="1b6d73"></a>QLabel::setAutoMask ( bool b ) <code>[virtual]</code></h3>
|
|---|
| 203 | <p>Reimplemented for internal reasons; the API is not affected.
|
|---|
| 204 | <p>Reimplemented from <a href="qwidget.html#c7a335">QWidget.</a>
|
|---|
| 205 | <h3 class="fn">void <a name="c0e104"></a>QLabel::setAutoResize ( bool enable ) <code>[virtual]</code></h3>
|
|---|
| 206 | <p><b>This function is obsolete.</b> It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.<p>
|
|---|
| 207 | Enables auto-resizing if <em>enable</em> is TRUE, or disables it if <em>enable</em> is FALSE.
|
|---|
| 208 | <p>When auto-resizing is enabled, the label will resize itself to fit
|
|---|
| 209 | the contents whenever the contents change. The top left corner is
|
|---|
| 210 | not moved. This is useful for QLabel widgets that are not managed by
|
|---|
| 211 | a <a href="qlayout.html">QLayout</a> (e.g. top-level widgets).
|
|---|
| 212 | <p>Auto-resizing is disabled by default.
|
|---|
| 213 | <p>See also <a href="#75b2a1">autoResize</a>(), <a href="qwidget.html#ab3108">adjustSize</a>() and <a href="#614dd5">sizeHint</a>().
|
|---|
| 214 | <h3 class="fn">void <a name="191701"></a>QLabel::setBuddy ( <a href="qwidget.html">QWidget</a> * buddy ) <code>[virtual]</code></h3>
|
|---|
| 215 | <p>Sets the buddy of this label to <em>buddy.</em>
|
|---|
| 216 | <p>When the user presses the accelerator key indicated by this label,
|
|---|
| 217 | the keyboard focus is transferred to the label's buddy widget.
|
|---|
| 218 | <p>The buddy mechanism is only available for QLabels that contain a
|
|---|
| 219 | plain text in which one letter is prefixed with '&'. It is this
|
|---|
| 220 | letter that is set as the accelerator key. The letter is displayed
|
|---|
| 221 | underlined, and the '&' is not displayed (i.e. the <code>ShowPrefix</code>
|
|---|
| 222 | alignment flag is turned on; see <a href="#1f406e">setAlignment</a>()).
|
|---|
| 223 | <p>In a dialog, you might create two data entry widgets and a label for
|
|---|
| 224 | each, and set up the geometry layout so each label is just to the
|
|---|
| 225 | left of its data entry widget (its "buddy"), somewhat like this:
|
|---|
| 226 | <p><pre> <a href="qlineedit.html">QLineEdit</a> *nameEd = new <a href="qlineedit.html">QLineEdit</a>( this );
|
|---|
| 227 | <a href="qlabel.html">QLabel</a> *nameLb = new <a href="qlabel.html">QLabel</a>( "&Name:", this );
|
|---|
| 228 | nameLb-><a href="#191701">setBuddy</a>( nameEd );
|
|---|
| 229 | <a href="qlineedit.html">QLineEdit</a> *phoneEd = new <a href="qlineedit.html">QLineEdit</a>( this );
|
|---|
| 230 | <a href="qlabel.html">QLabel</a> *phoneLb = new <a href="qlabel.html">QLabel</a>( "&Phone:", this );
|
|---|
| 231 | phoneLb-><a href="#191701">setBuddy</a>( phoneEd );
|
|---|
| 232 | // ( layout setup not shown )
|
|---|
| 233 | </pre>
|
|---|
| 234 | <p>With the code above, the focus jumps to the Name field when the user
|
|---|
| 235 | presses Alt-N, and to the Phone field when the user presses Alt-P.
|
|---|
| 236 | <p>To unset a previously set buddy, call this function with <em>buddy</em>
|
|---|
| 237 | set to 0.
|
|---|
| 238 | <p>See also <a href="#123954">buddy</a>(), <a href="#dffb43">setText</a>(), <a href="qaccel.html">QAccel</a> and <a href="#1f406e">setAlignment</a>().
|
|---|
| 239 | <p>Examples:
|
|---|
| 240 | <a href="layout-layout-cpp.html#setBuddy">layout/layout.cpp</a>
|
|---|
| 241 | <h3 class="fn">void <a name="ed9b8b"></a>QLabel::setIndent ( int indent )</h3>
|
|---|
| 242 | <p>Sets the indent of the label to <em>indent</em> pixels.
|
|---|
| 243 | <p>The indent applies to the left edge if <a href="#2fcaa3">alignment</a>() is <code>AlignLeft,</code>
|
|---|
| 244 | to the right edge if alignment() is <code>AlignRight,</code> to the top edge
|
|---|
| 245 | if alignment() is <code>AlignTop,</code> and to to the bottom edge if
|
|---|
| 246 | alignment() is <code>AlignBottom.</code>
|
|---|
| 247 | <p>If <em>indent</em> is negative, or if no indent has been set, the label
|
|---|
| 248 | computes the effective indent as follows: If <a href="qframe.html#e0ccef">frameWidth</a>() is 0, the
|
|---|
| 249 | effective indent becomes 0. If frameWidth() is greater than 0, the
|
|---|
| 250 | effective indent becomes half the width of the "x" character of the
|
|---|
| 251 | widget's current <a href="qwidget.html#3a7237">font</a>().
|
|---|
| 252 | <p>If <em>indent</em> is non-negative, the effective indent is <em>indent</em>
|
|---|
| 253 | pixels.
|
|---|
| 254 | <p>See also <a href="#e3c907">indent</a>(), <a href="#1f406e">setAlignment</a>(), <a href="qframe.html#e0ccef">frameWidth</a>() and <a href="qwidget.html#3a7237">font</a>().
|
|---|
| 255 | <p>Examples:
|
|---|
| 256 | <a href="movies-main-cpp.html#setIndent">movies/main.cpp</a>
|
|---|
| 257 | <h3 class="fn">void <a name="60de9f"></a>QLabel::setMovie ( const <a href="qmovie.html">QMovie</a> & movie ) <code>[virtual slot]</code></h3>
|
|---|
| 258 | <p>Sets the label contents to <em>movie.</em> Any previous content is cleared.
|
|---|
| 259 | <p>The buddy accelerator, if any, is disabled.
|
|---|
| 260 | <p>The label resizes itself if auto-resizing is enabled.
|
|---|
| 261 | <p>See also <a href="#7dcdfe">movie</a>() and <a href="#191701">setBuddy</a>().
|
|---|
| 262 | <h3 class="fn">void <a name="1a8f6a"></a>QLabel::setNum ( double num ) <code>[virtual slot]</code></h3>
|
|---|
| 263 | <p>Sets the label contents to a plain text containing the printed value
|
|---|
| 264 | of <em>num.</em> Does nothing if this is equal to the current contents of
|
|---|
| 265 | the label. Any previous content is cleared.
|
|---|
| 266 | <p>The buddy accelerator, if any, is disabled.
|
|---|
| 267 | <p>The label resizes itself if auto-resizing is enabled.
|
|---|
| 268 | <p>See also <a href="#dffb43">setText</a>(), <a href="qstring.html#01d80b">QString::setNum</a>() and <a href="#191701">setBuddy</a>().
|
|---|
| 269 | <h3 class="fn">void <a name="301e3c"></a>QLabel::setNum ( int num ) <code>[virtual slot]</code></h3>
|
|---|
| 270 | <p>Sets the label contents to a plain text containing the printed value
|
|---|
| 271 | of <em>num.</em> Does nothing if this is equal to the current contents of
|
|---|
| 272 | the label. Any previous content is cleared.
|
|---|
| 273 | <p>The buddy accelerator, if any, is disabled.
|
|---|
| 274 | <p>The label resizes itself if auto-resizing is enabled.
|
|---|
| 275 | <p>See also <a href="#dffb43">setText</a>(), <a href="qstring.html#01d80b">QString::setNum</a>() and <a href="#191701">setBuddy</a>().
|
|---|
| 276 | <h3 class="fn">void <a name="f3f301"></a>QLabel::setPixmap ( const <a href="qpixmap.html">QPixmap</a> & pixmap ) <code>[virtual slot]</code></h3>
|
|---|
| 277 | <p>Sets the label contents to <em>pixmap.</em> Any previous content is cleared.
|
|---|
| 278 | <p>The buddy accelerator, if any, is disabled.
|
|---|
| 279 | <p>The label resizes itself if auto-resizing is enabled.
|
|---|
| 280 | <p>See also <a href="#101ecb">pixmap</a>() and <a href="#191701">setBuddy</a>().
|
|---|
| 281 | <h3 class="fn">void <a name="e9e3cf"></a>QLabel::setScaledContents ( bool enable )</h3>
|
|---|
| 282 | <p>When called with <em>enable</em> == TRUE, and the label shows a pixmap,
|
|---|
| 283 | it will scale the pixmap to fill available space.
|
|---|
| 284 | <p>See also <a href="#7e1f73">hasScaledContents</a>().
|
|---|
| 285 | <h3 class="fn">void <a name="dffb43"></a>QLabel::setText ( const <a href="qstring.html">QString</a> & text ) <code>[virtual slot]</code></h3>
|
|---|
| 286 | <p>Sets the label contents to <em>text,</em> or does nothing if <em>text</em> is
|
|---|
| 287 | equal to the current contents of the label. Any previous content is
|
|---|
| 288 | cleared.
|
|---|
| 289 | <p><em>text</em> will be interpreted either as a plain text or as a rich
|
|---|
| 290 | text, depending on the text format setting; see <a href="#5de3f9">setTextFormat</a>(). The
|
|---|
| 291 | default setting is <code>AutoText,</code> i.e. QLabel will try to auto-detect
|
|---|
| 292 | the format of <em>text.</em>
|
|---|
| 293 | <p>If <em>text</em> is interpreted as a plain text, and a buddy has been set,
|
|---|
| 294 | the buddy accelerator key is updated from the new text.
|
|---|
| 295 | <p>The label resizes itself if auto-resizing is enabled.
|
|---|
| 296 | <p>Note that Qlabel is well suited to display small rich text documents
|
|---|
| 297 | only. For large documents, use <a href="qtextview.html">QTextView</a> instead. It will flicker
|
|---|
| 298 | less on resize and can also provide a scrollbar if necessary.
|
|---|
| 299 | <p>See also <a href="#72cf09">text</a>(), <a href="#5de3f9">setTextFormat</a>(), <a href="#191701">setBuddy</a>() and <a href="#1f406e">setAlignment</a>().
|
|---|
| 300 | <p>Examples:
|
|---|
| 301 | <a href="cursor-cursor-cpp.html#setText">cursor/cursor.cpp</a>
|
|---|
| 302 | <a href="layout-layout-cpp.html#setText">layout/layout.cpp</a>
|
|---|
| 303 | <a href="popup-popup-cpp.html#setText">popup/popup.cpp</a>
|
|---|
| 304 | <a href="qmag-qmag-cpp.html#setText">qmag/qmag.cpp</a>
|
|---|
| 305 | <a href="customlayout-main-cpp.html#setText">customlayout/main.cpp</a>
|
|---|
| 306 | <h3 class="fn">void <a name="5de3f9"></a>QLabel::setTextFormat ( <a href="qt.html#TextFormat">Qt::TextFormat</a> format )</h3>
|
|---|
| 307 | <p>Sets the text format to <em>format.</em> See the <a href="qt.html#TextFormat">Qt::TextFormat</a> enum for
|
|---|
| 308 | an explanation of the possible options.
|
|---|
| 309 | <p>The default format is <code>AutoText.</code>
|
|---|
| 310 | <p>See also <a href="#0b92ed">textFormat</a>() and <a href="#dffb43">setText</a>().
|
|---|
| 311 | <h3 class="fn"><a href="qsize.html">QSize</a> <a name="614dd5"></a>QLabel::sizeHint () const <code>[virtual]</code></h3>
|
|---|
| 312 | <p>Reimplemented for internal reasons; the API is not affected.
|
|---|
| 313 | <p>Examples:
|
|---|
| 314 | <a href="layout-layout-cpp.html#sizeHint">layout/layout.cpp</a>
|
|---|
| 315 | <p>Reimplemented from <a href="qwidget.html#290bcd">QWidget.</a>
|
|---|
| 316 | <h3 class="fn"><a href="qsizepolicy.html">QSizePolicy</a> <a name="26e1d9"></a>QLabel::sizePolicy () const <code>[virtual]</code></h3>
|
|---|
| 317 | <p>Reimplemented for internal reasons; the API is not affected.
|
|---|
| 318 | <p>Reimplemented from <a href="qwidget.html#2d5d13">QWidget.</a>
|
|---|
| 319 | <h3 class="fn"><a href="qstring.html">QString</a> <a name="72cf09"></a>QLabel::text () const</h3>
|
|---|
| 320 | <p>Returns the label text. If the content is a plain or a rich text,
|
|---|
| 321 | this is the string that was passed to <a href="#dffb43">setText</a>(). Otherwise, it is an
|
|---|
| 322 | empty/null string.
|
|---|
| 323 | <p>See also <a href="#dffb43">setText</a>(), <a href="#1a8f6a">setNum</a>() and <a href="#be73f3">clear</a>().
|
|---|
| 324 | <h3 class="fn">Qt::TextFormat <a name="0b92ed"></a>QLabel::textFormat() const</h3>
|
|---|
| 325 | <p>Returns the current text format.
|
|---|
| 326 | <p>See also <a href="#5de3f9">setTextFormat</a>().
|
|---|
| 327 | <hr><p>
|
|---|
| 328 | Search the documentation, FAQ, qt-interest archive and more (uses
|
|---|
| 329 | <a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
|
|---|
| 330 | <form method=post action="http://www.trolltech.com/search.cgi">
|
|---|
| 331 | <input type=hidden name="version" value="3.0.0-snapshot"><nobr>
|
|---|
| 332 | <input size="50" name="search"><input type=submit value="Search">
|
|---|
| 333 | </nobr></form><hr><p>
|
|---|
| 334 | This file is part of the <a href="index.html">Qt toolkit</a>,
|
|---|
| 335 | copyright © 1995-2000
|
|---|
| 336 | <a href="http://www.trolltech.com">Trolltech</a>, all rights reserved.<p><address><hr><div align="center">
|
|---|
| 337 | <table width="100%" cellspacing="0" border="0"><tr>
|
|---|
| 338 | <td>Copyright © 2000 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
|
|---|
| 339 | <td align="right"><div align="right">Qt version 3.0.0-snapshot</div>
|
|---|
| 340 | </table></div></address></body></html>
|
|---|