1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qlabel.cpp:66 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QLabel Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td 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="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped Classes</font></a>
| <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QLabel Class Reference</h1>
<p>The QLabel widget provides a text or image display.
<a href="#details">More...</a>
<p><tt>#include <<a href="qlabel-h.html">qlabel.h</a>></tt>
<p>Inherits <a href="qframe.html">QFrame</a>.
<p><a href="qlabel-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#QLabel"><b>QLabel</b></a> ( QWidget * parent, const char * name = 0, WFlags f = 0 )</li>
<li class=fn><a href="#QLabel-2"><b>QLabel</b></a> ( const QString & text, QWidget * parent, const char * name = 0, WFlags f = 0 )</li>
<li class=fn><a href="#QLabel-3"><b>QLabel</b></a> ( QWidget * buddy, const QString & text, QWidget * parent, const char * name = 0, WFlags f = 0 )</li>
<li class=fn><a href="#~QLabel"><b>~QLabel</b></a> ()</li>
<li class=fn>QString <a href="#text"><b>text</b></a> () const</li>
<li class=fn>QPixmap * <a href="#pixmap"><b>pixmap</b></a> () const</li>
<li class=fn>QPicture * <a href="#picture"><b>picture</b></a> () const</li>
<li class=fn>QMovie * <a href="#movie"><b>movie</b></a> () const</li>
<li class=fn>TextFormat <a href="#textFormat"><b>textFormat</b></a> () const</li>
<li class=fn>void <a href="#setTextFormat"><b>setTextFormat</b></a> ( TextFormat )</li>
<li class=fn>int <a href="#alignment"><b>alignment</b></a> () const</li>
<li class=fn>virtual void <a href="#setAlignment"><b>setAlignment</b></a> ( int )</li>
<li class=fn>int <a href="#indent"><b>indent</b></a> () const</li>
<li class=fn>void <a href="#setIndent"><b>setIndent</b></a> ( int )</li>
<li class=fn>bool autoResize () const <em>(obsolete)</em></li>
<li class=fn>virtual void setAutoResize ( bool enable ) <em>(obsolete)</em></li>
<li class=fn>bool <a href="#hasScaledContents"><b>hasScaledContents</b></a> () const</li>
<li class=fn>void <a href="#setScaledContents"><b>setScaledContents</b></a> ( bool )</li>
<li class=fn>virtual void <a href="#setBuddy"><b>setBuddy</b></a> ( QWidget * buddy )</li>
<li class=fn>QWidget * <a href="#buddy"><b>buddy</b></a> () const</li>
<li class=fn>virtual void <a href="#setFont"><b>setFont</b></a> ( const QFont & f )</li>
</ul>
<h2>Public Slots</h2>
<ul>
<li class=fn>virtual void <a href="#setText"><b>setText</b></a> ( const QString & )</li>
<li class=fn>virtual void <a href="#setPixmap"><b>setPixmap</b></a> ( const QPixmap & )</li>
<li class=fn>virtual void <a href="#setPicture"><b>setPicture</b></a> ( const QPicture & picture )</li>
<li class=fn>virtual void <a href="#setMovie"><b>setMovie</b></a> ( const QMovie & movie )</li>
<li class=fn>virtual void <a href="#setNum"><b>setNum</b></a> ( int num )</li>
<li class=fn>virtual void <a href="#setNum-2"><b>setNum</b></a> ( double num )</li>
<li class=fn>void <a href="#clear"><b>clear</b></a> ()</li>
</ul>
<h2>Properties</h2>
<ul>
<li class=fn>Alignment <a href="#alignment-prop"><b>alignment</b></a> - the alignment of the label's contents</li>
<li class=fn>BackgroundMode <a href="#backgroundMode-prop"><b>backgroundMode</b></a> - the label's background mode <em>(read only)</em></li>
<li class=fn>int <a href="#indent-prop"><b>indent</b></a> - the label's text indent in pixels</li>
<li class=fn>QPixmap <a href="#pixmap-prop"><b>pixmap</b></a> - the label's pixmap</li>
<li class=fn>bool <a href="#scaledContents-prop"><b>scaledContents</b></a> - whether the label will scale its contents to fill all available space</li>
<li class=fn>QString <a href="#text-prop"><b>text</b></a> - the label's text</li>
<li class=fn>TextFormat <a href="#textFormat-prop"><b>textFormat</b></a> - the label's text format</li>
</ul>
<h2>Protected Members</h2>
<ul>
<li class=fn>virtual void <a href="#drawContents"><b>drawContents</b></a> ( QPainter * p )</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
The QLabel widget provides a text or image display.
<p>
<p> QLabel is used for displaying text or an image. No user
interaction functionality is provided. The visual appearance of
the label can be configured in various ways, and it can be used
for specifying a focus accelerator key for another widget.
<p> A QLabel can contain any of the following content types:
<center><table cellpadding="4" cellspacing="2" border="0">
<tr bgcolor="#a2c511"> <th valign="top">Content <th valign="top">Setting
<tr bgcolor="#f0f0f0"> <td valign="top">Plain text
<td valign="top">Pass a <a href="qstring.html">QString</a> to <a href="#setText">setText</a>().
<tr bgcolor="#d0d0d0"> <td valign="top">Rich text
<td valign="top">Pass a QString that contains rich text to setText().
<tr bgcolor="#f0f0f0"> <td valign="top">A pixmap
<td valign="top">Pass a <a href="qpixmap.html">QPixmap</a> to <a href="#setPixmap">setPixmap</a>().
<tr bgcolor="#d0d0d0"> <td valign="top">A movie
<td valign="top">Pass a <a href="qmovie.html">QMovie</a> to <a href="#setMovie">setMovie</a>().
<tr bgcolor="#f0f0f0"> <td valign="top">A number
<td valign="top">Pass an <em>int</em> or a <em>double</em> to <a href="#setNum">setNum</a>(), which converts
the number to plain text.
<tr bgcolor="#d0d0d0"> <td valign="top">Nothing
<td valign="top">The same as an empty plain text. This is the default. Set
by <a href="#clear">clear</a>().
</table></center>
<p> When the content is changed using any of these functions, any
previous content is cleared.
<p> The look of a QLabel can be tuned in several ways. All the
settings of <a href="qframe.html">QFrame</a> are available for specifying a widget frame.
The positioning of the content within the QLabel widget area can
be tuned with <a href="#setAlignment">setAlignment</a>() and <a href="#setIndent">setIndent</a>(). For example, this
code sets up a sunken panel with a two-line text in the bottom
right corner (both lines being flush with the right side of the
label):
<pre>
QLabel *label = new QLabel( this );
label-><a href="qframe.html#setFrameStyle">setFrameStyle</a>( QFrame::<a href="qframe.html#Shape-enum">Panel</a> | QFrame::<a href="qframe.html#Shadow-enum">Sunken</a> );
label-><a href="#setText">setText</a>( "first line\nsecond line" );
label-><a href="#setAlignment">setAlignment</a>( AlignBottom | AlignRight );
</pre>
<p> A QLabel is often used as a label for an interactive widget. For
this use QLabel provides a useful mechanism for adding an
accelerator key (see <a href="qaccel.html">QAccel</a>) that will set the <a href="focus.html#keyboard-focus">keyboard focus</a> to
the other widget (called the QLabel's "buddy"). For example:
<pre>
<a href="qlineedit.html">QLineEdit</a>* phoneEdit = new <a href="qlineedit.html">QLineEdit</a>( this, "phoneEdit" );
QLabel* phoneLabel = new QLabel( phoneEdit, "&Phone:", this, "phoneLabel" );
</pre>
<p> In this example, keyboard focus is transferred to the label's
buddy (the <a href="qlineedit.html">QLineEdit</a>) when the user presses Alt+P. You can
also use the <a href="#setBuddy">setBuddy</a>() function to accomplish the same thing.
<p> <img src=qlabel-m.png> <img src=qlabel-w.png>
<p> <p>See also <a href="qlineedit.html">QLineEdit</a>, <a href="qtextedit.html">QTextEdit</a>, <a href="qpixmap.html">QPixmap</a>, <a href="qmovie.html">QMovie</a>, <a href="guibooks.html#fowler">GUI Design Handbook: Label</a>, <a href="basic.html">Basic Widgets</a>, and <a href="text.html">Text Related Classes</a>.
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QLabel"></a>QLabel::QLabel ( <a href="qwidget.html">QWidget</a> * parent, const char * name = 0, WFlags f = 0 )
</h3>
Constructs an empty label.
<p> The <em>parent</em>, <em>name</em> and <a href="qt.html#WidgetFlags">widget flag</a> <em>f</em>, arguments are passed
to the <a href="qframe.html">QFrame</a> constructor.
<p> <p>See also <a href="#alignment-prop">alignment</a>, <a href="qframe.html#setFrameStyle">setFrameStyle</a>(), and <a href="#indent-prop">indent</a>.
<h3 class=fn><a name="QLabel-2"></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>
Constructs a label that displays the text, <em>text</em>.
<p> The <em>parent</em>, <em>name</em> and <a href="qt.html#WidgetFlags">widget flag</a> <em>f</em>, arguments are passed
to the <a href="qframe.html">QFrame</a> constructor.
<p> <p>See also <a href="#text-prop">text</a>, <a href="#alignment-prop">alignment</a>, <a href="qframe.html#setFrameStyle">setFrameStyle</a>(), and <a href="#indent-prop">indent</a>.
<h3 class=fn><a name="QLabel-3"></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>
Constructs a label that displays the text <em>text</em>. The label has a
buddy widget, <em>buddy</em>.
<p> If the <em>text</em> contains an underlined letter (a letter preceded by
an ampersand, &), and the text is in plain text format, when the
user presses Alt+ the underlined letter, focus is passed to the
buddy widget.
<p> The <em>parent</em>, <em>name</em> and <a href="qt.html#WidgetFlags">widget flag</a>, <em>f</em>, arguments are passed
to the <a href="qframe.html">QFrame</a> constructor.
<p> <p>See also <a href="#text-prop">text</a>, <a href="#setBuddy">setBuddy</a>(), <a href="#alignment-prop">alignment</a>, <a href="qframe.html#setFrameStyle">setFrameStyle</a>(), and <a href="#indent-prop">indent</a>.
<h3 class=fn><a name="~QLabel"></a>QLabel::~QLabel ()
</h3>
Destroys the label.
<h3 class=fn>int <a name="alignment"></a>QLabel::alignment () const
</h3><p>Returns the alignment of the label's contents.
See the <a href="qlabel.html#alignment-prop">"alignment"</a> property for details.
<h3 class=fn>bool <a name="autoResize"></a>QLabel::autoResize () const
</h3>
<p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p> Returns TRUE if auto-resizing is enabled, or FALSE if auto-resizing
is disabled.
<p> Auto-resizing is disabled by default.
<p> <p>See also <a href="#setAutoResize">setAutoResize</a>().
<h3 class=fn><a href="qwidget.html">QWidget</a> * <a name="buddy"></a>QLabel::buddy () const
</h3>
Returns this label's buddy, or 0 if no buddy is currently set.
<p> <p>See also <a href="#setBuddy">setBuddy</a>().
<h3 class=fn>void <a name="clear"></a>QLabel::clear ()<tt> [slot]</tt>
</h3>
Clears any label contents. Equivalent to <a href="#setText">setText</a>( "" ).
<h3 class=fn>void <a name="drawContents"></a>QLabel::drawContents ( <a href="qpainter.html">QPainter</a> * p )<tt> [virtual protected]</tt>
</h3>
Draws the label contents using the painter <em>p</em>.
<p>Reimplemented from <a href="qframe.html#drawContents">QFrame</a>.
<h3 class=fn>bool <a name="hasScaledContents"></a>QLabel::hasScaledContents () const
</h3><p>Returns TRUE if the label will scale its contents to fill all available space; otherwise returns FALSE.
See the <a href="qlabel.html#scaledContents-prop">"scaledContents"</a> property for details.
<h3 class=fn>int <a name="indent"></a>QLabel::indent () const
</h3><p>Returns the label's text indent in pixels.
See the <a href="qlabel.html#indent-prop">"indent"</a> property for details.
<h3 class=fn><a href="qmovie.html">QMovie</a> * <a name="movie"></a>QLabel::movie () const
</h3>
Returns a pointer to the label's movie, or 0 if no movie has been
set.
<p> <p>See also <a href="#setMovie">setMovie</a>().
<h3 class=fn><a href="qpicture.html">QPicture</a> * <a name="picture"></a>QLabel::picture () const
</h3>
<p> Returns the label's picture or 0 if the label doesn't have a
picture.
<h3 class=fn><a href="qpixmap.html">QPixmap</a> * <a name="pixmap"></a>QLabel::pixmap () const
</h3><p>Returns the label's pixmap.
See the <a href="qlabel.html#pixmap-prop">"pixmap"</a> property for details.
<h3 class=fn>void <a name="setAlignment"></a>QLabel::setAlignment ( int )<tt> [virtual]</tt>
</h3><p>Sets the alignment of the label's contents.
See the <a href="qlabel.html#alignment-prop">"alignment"</a> property for details.
<h3 class=fn>void <a name="setAutoResize"></a>QLabel::setAutoResize ( bool enable )<tt> [virtual]</tt>
</h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p> Enables auto-resizing if <em>enable</em> is TRUE, or disables it if <em>enable</em> is FALSE.
<p> When auto-resizing is enabled the label will resize itself to fit
the contents whenever the contents change. The top-left corner is
not moved. This is useful for QLabel widgets that are not managed by
a <a href="qlayout.html">QLayout</a> (e.g., top-level widgets).
<p> Auto-resizing is disabled by default.
<p> <p>See also <a href="#autoResize">autoResize</a>(), <a href="qwidget.html#adjustSize">adjustSize</a>(), and <a href="qwidget.html#sizeHint-prop">sizeHint</a>.
<h3 class=fn>void <a name="setBuddy"></a>QLabel::setBuddy ( <a href="qwidget.html">QWidget</a> * buddy )<tt> [virtual]</tt>
</h3>
Sets this label's buddy to <em>buddy</em>.
<p> When the user presses the accelerator key indicated by this label,
the <a href="focus.html#keyboard-focus">keyboard focus</a> is transferred to the label's buddy widget.
<p> The buddy mechanism is only available for QLabels that contain
plain text in which one letter is prefixed with an ampersand, &.
This letter is set as the accelerator key. The letter is displayed
underlined, and the '&' is not displayed (i.e. the <a href="qt.html#TextFlags-enum">ShowPrefix</a>
alignment flag is turned on; see <a href="#setAlignment">setAlignment</a>()).
<p> In a dialog, you might create two data entry widgets and a label
for each, and set up the geometry layout so each label is just to
the left of its data entry widget (its "buddy"), for example:
<pre>
<a href="qlineedit.html">QLineEdit</a> *nameEd = new <a href="qlineedit.html">QLineEdit</a>( this );
QLabel *nameLb = new QLabel( "&Name:", this );
nameLb-><a href="#setBuddy">setBuddy</a>( nameEd );
<a href="qlineedit.html">QLineEdit</a> *phoneEd = new <a href="qlineedit.html">QLineEdit</a>( this );
QLabel *phoneLb = new QLabel( "&Phone:", this );
phoneLb-><a href="#setBuddy">setBuddy</a>( phoneEd );
// ( layout setup not shown )
</pre>
<p> With the code above, the focus jumps to the Name field when the
user presses Alt+N, and to the Phone field when the user presses
Alt+P.
<p> To unset a previously set buddy, call this function with <em>buddy</em>
set to 0.
<p> <p>See also <a href="#buddy">buddy</a>(), <a href="#text-prop">text</a>, <a href="qaccel.html">QAccel</a>, and <a href="#alignment-prop">alignment</a>.
<p>Examples: <a href="addressbook-example.html#x580">addressbook/centralwidget.cpp</a>, <a href="tutorial2-09.html#x2642">chart/optionsform.cpp</a>, and <a href="regexptester-example.html#x2482">regexptester/regexptester.cpp</a>.
<h3 class=fn>void <a name="setFont"></a>QLabel::setFont ( const <a href="qfont.html">QFont</a> & f )<tt> [virtual]</tt>
</h3>
Sets the font used on the QLabel to font <em>f</em>.
<p>Example: <a href="menu-example.html#x1865">menu/menu.cpp</a>.
<p>Reimplemented from <a href="qwidget.html#setFont">QWidget</a>.
<h3 class=fn>void <a name="setIndent"></a>QLabel::setIndent ( int )
</h3><p>Sets the label's text indent in pixels.
See the <a href="qlabel.html#indent-prop">"indent"</a> property for details.
<h3 class=fn>void <a name="setMovie"></a>QLabel::setMovie ( const <a href="qmovie.html">QMovie</a> & movie )<tt> [virtual slot]</tt>
</h3>
Sets the label contents to <em>movie</em>. Any previous content is
cleared.
<p> The buddy accelerator, if any, is disabled.
<p> The label resizes itself if auto-resizing is enabled.
<p> <p>See also <a href="#movie">movie</a>() and <a href="#setBuddy">setBuddy</a>().
<h3 class=fn>void <a name="setNum"></a>QLabel::setNum ( int num )<tt> [virtual slot]</tt>
</h3>
Sets the label contents to plain text containing the textual
representation of integer <em>num</em>. Any previous content is cleared.
Does nothing if the integer's string representation is the same as
the current contents of the label.
<p> The buddy accelerator, if any, is disabled.
<p> The label resizes itself if auto-resizing is enabled.
<p> <p>See also <a href="#text-prop">text</a>, <a href="qstring.html#setNum">QString::setNum</a>(), and <a href="#setBuddy">setBuddy</a>().
<h3 class=fn>void <a name="setNum-2"></a>QLabel::setNum ( double num )<tt> [virtual slot]</tt>
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Sets the label contents to plain text containing the textual
representation of double <em>num</em>. Any previous content is cleared.
Does nothing if the double's string representation is the same as
the current contents of the label.
<p> The buddy accelerator, if any, is disabled.
<p> The label resizes itself if auto-resizing is enabled.
<p> <p>See also <a href="#text-prop">text</a>, <a href="qstring.html#setNum">QString::setNum</a>(), and <a href="#setBuddy">setBuddy</a>().
<h3 class=fn>void <a name="setPicture"></a>QLabel::setPicture ( const <a href="qpicture.html">QPicture</a> & picture )<tt> [virtual slot]</tt>
</h3>
Sets the label contents to <em>picture</em>. Any previous content is
cleared.
<p> The buddy accelerator, if any, is disabled.
<p> <p>See also <a href="#picture">picture</a>() and <a href="#setBuddy">setBuddy</a>().
<h3 class=fn>void <a name="setPixmap"></a>QLabel::setPixmap ( const <a href="qpixmap.html">QPixmap</a> & )<tt> [virtual slot]</tt>
</h3><p>Sets the label's pixmap.
See the <a href="qlabel.html#pixmap-prop">"pixmap"</a> property for details.
<h3 class=fn>void <a name="setScaledContents"></a>QLabel::setScaledContents ( bool )
</h3><p>Sets whether the label will scale its contents to fill all available space.
See the <a href="qlabel.html#scaledContents-prop">"scaledContents"</a> property for details.
<h3 class=fn>void <a name="setText"></a>QLabel::setText ( const <a href="qstring.html">QString</a> & )<tt> [virtual slot]</tt>
</h3><p>Sets the label's text.
See the <a href="qlabel.html#text-prop">"text"</a> property for details.
<h3 class=fn>void <a name="setTextFormat"></a>QLabel::setTextFormat ( <a href="qt.html#TextFormat-enum">TextFormat</a> )
</h3><p>Sets the label's text format.
See the <a href="qlabel.html#textFormat-prop">"textFormat"</a> property for details.
<h3 class=fn><a href="qstring.html">QString</a> <a name="text"></a>QLabel::text () const
</h3><p>Returns the label's text.
See the <a href="qlabel.html#text-prop">"text"</a> property for details.
<h3 class=fn><a href="qt.html#TextFormat-enum">TextFormat</a> <a name="textFormat"></a>QLabel::textFormat () const
</h3><p>Returns the label's text format.
See the <a href="qlabel.html#textFormat-prop">"textFormat"</a> property for details.
<hr><h2>Property Documentation</h2>
<h3 class=fn>Alignment <a name="alignment-prop"></a>alignment</h3>
<p>This property holds the alignment of the label's contents.
<p>The alignment is a bitwise OR of <a href="qt.html#AlignmentFlags-enum">Qt::AlignmentFlags</a> and <a href="qt.html#TextFlags-enum">Qt::TextFlags</a> values. The <a href="qt.html#TextFlags-enum">ExpandTabs</a>, <a href="qt.html#TextFlags-enum">SingleLine</a> and <a href="qt.html#TextFlags-enum">ShowPrefix</a> flags apply only if the label contains plain text;
otherwise they are ignored. The <a href="qt.html#TextFlags-enum">DontClip</a> flag is always
ignored. <a href="qt.html#TextFlags-enum">WordBreak</a> applies to both rich text and plain text
labels. The <a href="qt.html#TextFlags-enum">BreakAnywhere</a> flag is not supported in QLabel.
<p> If the label has a buddy, the <a href="qt.html#TextFlags-enum">ShowPrefix</a> flag is forced to
TRUE.
<p> The default alignment is <tt>AlignAuto | AlignVCenter | ExpandTabs</tt>
if the label doesn't have a buddy and <tt>AlignAuto | AlignVCenter | ExpandTabs | ShowPrefix</tt> if the label has a buddy. If the label
contains rich text, additionally <a href="qt.html#TextFlags-enum">WordBreak</a> is turned on.
<p> <p>See also <a href="qt.html#AlignmentFlags-enum">Qt::AlignmentFlags</a>, <a href="#setBuddy">setBuddy</a>(), and <a href="#text-prop">text</a>.
<p>Set this property's value with <a href="#setAlignment">setAlignment</a>() and get this property's value with <a href="#alignment">alignment</a>().
<h3 class=fn><a href="qt.html#BackgroundMode-enum">BackgroundMode</a> <a name="backgroundMode-prop"></a>backgroundMode</h3>
<p>This property holds the label's background mode.
<p>Get this property with <a href="qwidget.html#backgroundMode">backgroundMode</a>().
<p> <p>See also <a href="qwidget.html#backgroundMode-prop">QWidget::backgroundMode</a>.
<p><h3 class=fn>int <a name="indent-prop"></a>indent</h3>
<p>This property holds the label's text indent in pixels.
<p>If a label displays text, the indent applies to the left edge if
<a href="#alignment">alignment</a>() is <a href="qt.html#AlignmentFlags-enum">AlignLeft</a>, to the right edge if alignment() is
<a href="qt.html#AlignmentFlags-enum">AlignRight</a>, to the top edge if alignment() is <a href="qt.html#AlignmentFlags-enum">AlignTop</a>, and
to to the bottom edge if alignment() is <a href="qt.html#AlignmentFlags-enum">AlignBottom</a>.
<p> If indent is negative, or if no indent has been set, the label
computes the effective indent as follows: If <a href="qframe.html#frameWidth">frameWidth</a>() is 0,
the effective indent becomes 0. If frameWidth() is greater than 0,
the effective indent becomes half the width of the "x" character
of the widget's current <a href="qwidget.html#font">font</a>().
<p> <p>See also <a href="#alignment-prop">alignment</a>, <a href="qframe.html#frameWidth-prop">frameWidth</a>, and <a href="qwidget.html#font-prop">font</a>.
<p>Set this property's value with <a href="#setIndent">setIndent</a>() and get this property's value with <a href="#indent">indent</a>().
<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="pixmap-prop"></a>pixmap</h3>
<p>This property holds the label's pixmap.
<p>If no pixmap has been set this will return an invalid pixmap.
<p> Setting the pixmap clears any previous content, and resizes the
label if <a href="#autoResize">QLabel::autoResize</a>() is TRUE. The buddy accelerator,
if any, is disabled.
<p>Set this property's value with <a href="#setPixmap">setPixmap</a>() and get this property's value with <a href="#pixmap">pixmap</a>().
<h3 class=fn>bool <a name="scaledContents-prop"></a>scaledContents</h3>
<p>This property holds whether the label will scale its contents to fill all available space.
<p>When enabled and the label shows a pixmap, it will scale the
pixmap to fill the available space.
<p> This property's default is FALSE.
<p> <p>See also <a href="#scaledContents-prop">scaledContents</a>.
<p>Set this property's value with <a href="#setScaledContents">setScaledContents</a>() and get this property's value with <a href="#hasScaledContents">hasScaledContents</a>().
<h3 class=fn><a href="qstring.html">QString</a> <a name="text-prop"></a>text</h3>
<p>This property holds the label's text.
<p>If no text has been set this will return an empty string. Setting
the text clears any previous content, unless they are the same.
<p> The text will be interpreted either as a plain text or as a rich
text, depending on the text format setting; see <a href="#setTextFormat">setTextFormat</a>().
The default setting is <a href="qt.html#TextFormat-enum">AutoText</a>, i.e. QLabel will try to
auto-detect the format of the text set.
<p> If the text is interpreted as a plain text and a buddy has been
set, the buddy accelerator key is updated from the new text.
<p> The label resizes itself if auto-resizing is enabled.
<p> Note that Qlabel is well-suited to display small rich text
documents, i.e. those small documents that get their document
specific settings (font, text color, link color) from the label's
palette and font properties. For large documents, use <a href="qtextedit.html">QTextEdit</a>
in read-only mode instead. QTextEdit will flicker less on resize
and can also provide a scrollbar when necessary.
<p> <p>See also <a href="#textFormat-prop">textFormat</a>, <a href="#setBuddy">setBuddy</a>(), and <a href="#alignment-prop">alignment</a>.
<p>Set this property's value with <a href="#setText">setText</a>() and get this property's value with <a href="#text">text</a>().
<h3 class=fn><a href="qt.html#TextFormat-enum">TextFormat</a> <a name="textFormat-prop"></a>textFormat</h3>
<p>This property holds the label's text format.
<p>See the <a href="qt.html#TextFormat-enum">Qt::TextFormat</a> enum for an explanation of the possible
options.
<p> The default format is <a href="qt.html#TextFormat-enum">AutoText</a>.
<p> <p>See also <a href="#text-prop">text</a>.
<p>Set this property's value with <a href="#setTextFormat">setTextFormat</a>() and get this property's value with <a href="#textFormat">textFormat</a>().
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright © 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright © 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt 3.3.8</div>
</table></div></address></body>
</html>
|