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