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 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qlabel.cpp -->
<title>Qt 4.8: QLabel Class Reference</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="content">
<a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
</div>
<div class="breadcrumb toolblock">
<ul>
<li class="first"><a href="index.html">Home</a></li>
<!-- Breadcrumbs go here -->
<li><a href="modules.html">Modules</a></li>
<li><a href="qtgui.html">QtGui</a></li>
<li>QLabel</li>
</ul>
</div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#properties">Properties</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#public-slots">Public Slots</a></li>
<li class="level1"><a href="#signals">Signals</a></li>
<li class="level1"><a href="#protected-functions">Protected Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<h1 class="title">QLabel Class Reference</h1>
<!-- $$$QLabel-brief -->
<p>The QLabel widget provides a text or image display. <a href="#details">More...</a></p>
<!-- @@@QLabel -->
<pre class="cpp"> <span class="preprocessor">#include <QLabel></span></pre><p><b>Inherits: </b><a href="qframe.html">QFrame</a>.</p>
<p><b>Inherited by: </b></p>
<ul>
<li><a href="qlabel-members.html">List of all members, including inherited members</a></li>
<li><a href="qlabel-qt3.html">Qt 3 support members</a></li>
</ul>
<a name="properties"></a>
<h2>Properties</h2>
<table class="propsummary">
<tr><td class="topAlign"><ul>
<li class="fn"><b><a href="qlabel.html#alignment-prop">alignment</a></b> : Qt::Alignment</li>
<li class="fn"><b><a href="qlabel.html#hasSelectedText-prop">hasSelectedText</a></b> : const bool</li>
<li class="fn"><b><a href="qlabel.html#indent-prop">indent</a></b> : int</li>
<li class="fn"><b><a href="qlabel.html#margin-prop">margin</a></b> : int</li>
<li class="fn"><b><a href="qlabel.html#openExternalLinks-prop">openExternalLinks</a></b> : bool</li>
<li class="fn"><b><a href="qlabel.html#pixmap-prop">pixmap</a></b> : QPixmap</li>
</ul></td><td class="topAlign"><ul>
<li class="fn"><b><a href="qlabel.html#scaledContents-prop">scaledContents</a></b> : bool</li>
<li class="fn"><b><a href="qlabel.html#selectedText-prop">selectedText</a></b> : const QString</li>
<li class="fn"><b><a href="qlabel.html#text-prop">text</a></b> : QString</li>
<li class="fn"><b><a href="qlabel.html#textFormat-prop">textFormat</a></b> : Qt::TextFormat</li>
<li class="fn"><b><a href="qlabel.html#textInteractionFlags-prop">textInteractionFlags</a></b> : Qt::TextInteractionFlags</li>
<li class="fn"><b><a href="qlabel.html#wordWrap-prop">wordWrap</a></b> : bool</li>
</ul>
</td></tr>
</table>
<ul>
<li class="fn">6 properties inherited from <a href="qframe.html#properties">QFrame</a></li>
<li class="fn">58 properties inherited from <a href="qwidget.html#properties">QWidget</a></li>
<li class="fn">1 property inherited from <a href="qobject.html#properties">QObject</a></li>
</ul>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#QLabel">QLabel</a></b> ( QWidget * <i>parent</i> = 0, Qt::WindowFlags <i>f</i> = 0 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#QLabel-2">QLabel</a></b> ( const QString & <i>text</i>, QWidget * <i>parent</i> = 0, Qt::WindowFlags <i>f</i> = 0 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#dtor.QLabel">~QLabel</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Qt::Alignment </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#alignment-prop">alignment</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QWidget * </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#buddy">buddy</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#scaledContents-prop">hasScaledContents</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#hasSelectedText-prop">hasSelectedText</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#indent-prop">indent</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#margin-prop">margin</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QMovie * </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#movie">movie</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#openExternalLinks-prop">openExternalLinks</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QPicture * </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#picture">picture</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QPixmap * </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#pixmap-prop">pixmap</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#selectedText-prop">selectedText</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#selectionStart">selectionStart</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#alignment-prop">setAlignment</a></b> ( Qt::Alignment )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#setBuddy">setBuddy</a></b> ( QWidget * <i>buddy</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#indent-prop">setIndent</a></b> ( int )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#margin-prop">setMargin</a></b> ( int )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#openExternalLinks-prop">setOpenExternalLinks</a></b> ( bool <i>open</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#scaledContents-prop">setScaledContents</a></b> ( bool )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#setSelection">setSelection</a></b> ( int <i>start</i>, int <i>length</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#textFormat-prop">setTextFormat</a></b> ( Qt::TextFormat )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#textInteractionFlags-prop">setTextInteractionFlags</a></b> ( Qt::TextInteractionFlags <i>flags</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#wordWrap-prop">setWordWrap</a></b> ( bool <i>on</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#text-prop">text</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Qt::TextFormat </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#textFormat-prop">textFormat</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Qt::TextInteractionFlags </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#textInteractionFlags-prop">textInteractionFlags</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#wordWrap-prop">wordWrap</a></b> () const</td></tr>
</table>
<a name="reimplemented-public-functions"></a>
<h2>Reimplemented Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual int </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#heightForWidth">heightForWidth</a></b> ( int <i>w</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QSize </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#minimumSizeHint">minimumSizeHint</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QSize </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#sizeHint">sizeHint</a></b> () const</td></tr>
</table>
<ul>
<li class="fn">14 public functions inherited from <a href="qframe.html#public-functions">QFrame</a></li>
<li class="fn">221 public functions inherited from <a href="qwidget.html#public-functions">QWidget</a></li>
<li class="fn">29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
<li class="fn">13 public functions inherited from <a href="qpaintdevice.html#public-functions">QPaintDevice</a></li>
</ul>
<a name="public-slots"></a>
<h2>Public Slots</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#clear">clear</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#setMovie">setMovie</a></b> ( QMovie * <i>movie</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#setNum">setNum</a></b> ( int <i>num</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#setNum-2">setNum</a></b> ( double <i>num</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#setPicture">setPicture</a></b> ( const QPicture & <i>picture</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#pixmap-prop">setPixmap</a></b> ( const QPixmap & )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#text-prop">setText</a></b> ( const QString & )</td></tr>
</table>
<ul>
<li class="fn">19 public slots inherited from <a href="qwidget.html#public-slots">QWidget</a></li>
<li class="fn">1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
</ul>
<a name="signals"></a>
<h2>Signals</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#linkActivated">linkActivated</a></b> ( const QString & <i>link</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#linkHovered">linkHovered</a></b> ( const QString & <i>link</i> )</td></tr>
</table>
<ul>
<li class="fn">1 signal inherited from <a href="qwidget.html#signals">QWidget</a></li>
<li class="fn">1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
</ul>
<a name="reimplemented-protected-functions"></a>
<h2>Reimplemented Protected Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#changeEvent">changeEvent</a></b> ( QEvent * <i>ev</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#contextMenuEvent">contextMenuEvent</a></b> ( QContextMenuEvent * <i>ev</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#event">event</a></b> ( QEvent * <i>e</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#focusInEvent">focusInEvent</a></b> ( QFocusEvent * <i>ev</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#focusNextPrevChild">focusNextPrevChild</a></b> ( bool <i>next</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#focusOutEvent">focusOutEvent</a></b> ( QFocusEvent * <i>ev</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#keyPressEvent">keyPressEvent</a></b> ( QKeyEvent * <i>ev</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#mouseMoveEvent">mouseMoveEvent</a></b> ( QMouseEvent * <i>ev</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#mousePressEvent">mousePressEvent</a></b> ( QMouseEvent * <i>ev</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#mouseReleaseEvent">mouseReleaseEvent</a></b> ( QMouseEvent * <i>ev</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qlabel.html#paintEvent">paintEvent</a></b> ( QPaintEvent * )</td></tr>
</table>
<ul>
<li class="fn">3 protected functions inherited from <a href="qframe.html#protected-functions">QFrame</a></li>
<li class="fn">37 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
<li class="fn">8 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
<li class="fn">1 protected function inherited from <a href="qpaintdevice.html#protected-functions">QPaintDevice</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">4 static public members inherited from <a href="qwidget.html#static-public-members">QWidget</a></li>
<li class="fn">7 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
<li class="fn">3 protected functions inherited from <a href="qframe.html#protected-functions">QFrame</a></li>
<li class="fn">37 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
<li class="fn">8 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
<li class="fn">1 protected function inherited from <a href="qpaintdevice.html#protected-functions">QPaintDevice</a></li>
<li class="fn">1 protected slot inherited from <a href="qwidget.html#protected-slots">QWidget</a></li>
</ul>
<a name="details"></a>
<!-- $$$QLabel-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>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 mnemonic key for another widget.</p>
<p>A QLabel can contain any of the following content types:</p>
<table class="generic">
<thead><tr class="qt-style"><th >Content</th><th >Setting</th></tr></thead>
<tr valign="top" class="odd"><td >Plain text</td><td >Pass a <a href="qstring.html">QString</a> to <a href="qlabel.html#text-prop">setText</a>().</td></tr>
<tr valign="top" class="even"><td >Rich text</td><td >Pass a <a href="qstring.html">QString</a> that contains rich text to <a href="qlabel.html#text-prop">setText</a>().</td></tr>
<tr valign="top" class="odd"><td >A pixmap</td><td >Pass a <a href="qpixmap.html">QPixmap</a> to <a href="qlabel.html#pixmap-prop">setPixmap</a>().</td></tr>
<tr valign="top" class="even"><td >A movie</td><td >Pass a <a href="qmovie.html">QMovie</a> to <a href="qlabel.html#setMovie">setMovie</a>().</td></tr>
<tr valign="top" class="odd"><td >A number</td><td >Pass an <i>int</i> or a <i>double</i> to <a href="qlabel.html#setNum">setNum</a>(), which converts the number to plain text.</td></tr>
<tr valign="top" class="even"><td >Nothing</td><td >The same as an empty plain text. This is the default. Set by <a href="qlabel.html#clear">clear</a>().</td></tr>
</table>
<p><b>Warning:</b> When passing a <a href="qstring.html">QString</a> to the constructor or calling <a href="qlabel.html#text-prop">setText</a>(), make sure to sanitize your input, as QLabel tries to guess whether it displays the text as plain text or as rich text. You may want to call <a href="qlabel.html#textFormat-prop">setTextFormat</a>() explicitly, e.g. in case you expect the text to be in plain format but cannot control the text source (for instance when displaying data loaded from the Web).</p>
<p>When the content is changed using any of these functions, any previous content is cleared.</p>
<p>By default, labels display <a href="qlabel.html#alignment-prop">left-aligned, vertically-centered</a> text and images, where any tabs in the text to be displayed are <a href="qt.html#TextFlag-enum">automatically expanded</a>. However, the look of a QLabel can be adjusted and fine-tuned in several ways.</p>
<p>The positioning of the content within the QLabel widget area can be tuned with <a href="qlabel.html#alignment-prop">setAlignment</a>() and <a href="qlabel.html#indent-prop">setIndent</a>(). Text content can also wrap lines along word boundaries with <a href="qlabel.html#wordWrap-prop">setWordWrap</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):</p>
<pre class="cpp"> <span class="type">QLabel</span> <span class="operator">*</span>label <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QLabel</span>(<span class="keyword">this</span>);
label<span class="operator">-</span><span class="operator">></span><a href="qframe.html#setFrameStyle">setFrameStyle</a>(<span class="type"><a href="qframe.html">QFrame</a></span><span class="operator">::</span>Panel <span class="operator">|</span> <span class="type"><a href="qframe.html">QFrame</a></span><span class="operator">::</span>Sunken);
label<span class="operator">-</span><span class="operator">></span><a href="qlabel.html#text-prop">setText</a>(<span class="string">"first line\nsecond line"</span>);
label<span class="operator">-</span><span class="operator">></span><a href="qlabel.html#alignment-prop">setAlignment</a>(<span class="type"><a href="qt.html">Qt</a></span><span class="operator">::</span>AlignBottom <span class="operator">|</span> <span class="type"><a href="qt.html">Qt</a></span><span class="operator">::</span>AlignRight);</pre>
<p>The properties and functions QLabel inherits from <a href="qframe.html">QFrame</a> can also be used to specify the widget frame to be used for any given label.</p>
<p>A QLabel is often used as a label for an interactive widget. For this use QLabel provides a useful mechanism for adding an mnemonic (see <a href="qkeysequence.html">QKeySequence</a>) that will set the keyboard focus to the other widget (called the QLabel's "buddy"). For example:</p>
<pre class="cpp"> <span class="type"><a href="qlineedit.html">QLineEdit</a></span><span class="operator">*</span> phoneEdit <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlineedit.html">QLineEdit</a></span>(<span class="keyword">this</span>);
<span class="type">QLabel</span><span class="operator">*</span> phoneLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QLabel</span>(<span class="string">"&Phone:"</span><span class="operator">,</span> <span class="keyword">this</span>);
phoneLabel<span class="operator">-</span><span class="operator">></span><a href="qlabel.html#setBuddy">setBuddy</a>(phoneEdit);</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. If the buddy was a button (inheriting from <a href="qabstractbutton.html">QAbstractButton</a>), triggering the mnemonic would emulate a button click.</p>
<table class="generic" width="100%">
<tr valign="top" class="odd"><td ><img src="images/macintosh-label.png" alt="Screenshot of a Macintosh style label" /></td><td >A label shown in the <a href="gallery-macintosh.html">Macintosh widget style</a>.</td></tr>
<tr valign="top" class="even"><td ><img src="images/plastique-label.png" alt="Screenshot of a Plastique style label" /></td><td >A label shown in the <a href="gallery-plastique.html">Plastique widget style</a>.</td></tr>
<tr valign="top" class="odd"><td ><img src="images/windowsxp-label.png" alt="Screenshot of a Windows XP style label" /></td><td >A label shown in the <a href="gallery-windowsxp.html">Windows XP widget style</a>.</td></tr>
</table>
</div>
<p><b>See also </b><a href="qlineedit.html">QLineEdit</a>, <a href="qtextedit.html">QTextEdit</a>, <a href="qpixmap.html">QPixmap</a>, <a href="qmovie.html">QMovie</a>, and <a href="guibooks.html#fowler">GUI Design Handbook: Label</a>.</p>
<!-- @@@QLabel -->
<div class="prop">
<h2>Property Documentation</h2>
<!-- $$$alignment-prop$$$alignment$$$setAlignmentQt::Alignment -->
<h3 class="fn"><a name="alignment-prop"></a><span class="name">alignment</span> : <span class="type"><a href="qt.html#AlignmentFlag-enum">Qt::Alignment</a></span></h3>
<p>This property holds the alignment of the label's contents.</p>
<p>By default, the contents of the label are left-aligned and vertically-centered.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> Qt::Alignment </td><td class="memItemRight bottomAlign"><span class="name"><b>alignment</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setAlignment</b></span> ( Qt::Alignment )</td></tr>
</table>
<p><b>See also </b><a href="qlabel.html#text-prop">text</a>.</p>
<!-- @@@alignment -->
<!-- $$$hasSelectedText-prop$$$hasSelectedText -->
<h3 class="fn"><a name="hasSelectedText-prop"></a><span class="name">hasSelectedText</span> : const <span class="type">bool</span></h3>
<p>This property holds whether there is any text selected.</p>
<p>hasSelectedText() returns true if some or all of the text has been selected by the user; otherwise returns false.</p>
<p>By default, this property is false.</p>
<p><b>Note:</b> The <a href="qlabel.html#textInteractionFlags-prop">textInteractionFlags</a> set on the label need to include either TextSelectableByMouse or TextSelectableByKeyboard.</p>
<p>This property was introduced in Qt 4.7.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> bool </td><td class="memItemRight bottomAlign"><span class="name"><b>hasSelectedText</b></span> () const</td></tr>
</table>
<p><b>See also </b><a href="qlabel.html#selectedText-prop">selectedText</a>().</p>
<!-- @@@hasSelectedText -->
<!-- $$$indent-prop$$$indent$$$setIndentint -->
<h3 class="fn"><a name="indent-prop"></a><span class="name">indent</span> : <span class="type">int</span></h3>
<p>This property holds the label's text indent in pixels.</p>
<p>If a label displays text, the indent applies to the left edge if <a href="qlabel.html#alignment-prop">alignment</a>() is <a href="qt.html#AlignmentFlag-enum">Qt::AlignLeft</a>, to the right edge if <a href="qlabel.html#alignment-prop">alignment</a>() is <a href="qt.html#AlignmentFlag-enum">Qt::AlignRight</a>, to the top edge if <a href="qlabel.html#alignment-prop">alignment</a>() is <a href="qt.html#AlignmentFlag-enum">Qt::AlignTop</a>, and to to the bottom edge if <a href="qlabel.html#alignment-prop">alignment</a>() is <a href="qt.html#AlignmentFlag-enum">Qt::AlignBottom</a>.</p>
<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-prop">frameWidth</a>() is 0, the effective indent becomes 0. If <a href="qframe.html#frameWidth-prop">frameWidth</a>() 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-prop">font</a>().</p>
<p>By default, the indent is -1, meaning that an effective indent is calculating in the manner described above.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>indent</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setIndent</b></span> ( int )</td></tr>
</table>
<p><b>See also </b><a href="qlabel.html#alignment-prop">alignment</a>, <a href="qlabel.html#margin-prop">margin</a>, <a href="qframe.html#frameWidth-prop">frameWidth</a>(), and <a href="qwidget.html#font-prop">font</a>().</p>
<!-- @@@indent -->
<!-- $$$margin-prop$$$margin$$$setMarginint -->
<h3 class="fn"><a name="margin-prop"></a><span class="name">margin</span> : <span class="type">int</span></h3>
<p>This property holds the width of the margin.</p>
<p>The margin is the distance between the innermost pixel of the frame and the outermost pixel of contents.</p>
<p>The default margin is 0.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>margin</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setMargin</b></span> ( int )</td></tr>
</table>
<p><b>See also </b><a href="qlabel.html#indent-prop">indent</a>.</p>
<!-- @@@margin -->
<!-- $$$openExternalLinks-prop$$$openExternalLinks$$$setOpenExternalLinksbool -->
<h3 class="fn"><a name="openExternalLinks-prop"></a><span class="name">openExternalLinks</span> : <span class="type">bool</span></h3>
<p>Specifies whether <a href="qlabel.html">QLabel</a> should automatically open links using <a href="qdesktopservices.html#openUrl">QDesktopServices::openUrl</a>() instead of emitting the <a href="qlabel.html#linkActivated">linkActivated</a>() signal.</p>
<p><b>Note:</b> The <a href="qlabel.html#textInteractionFlags-prop">textInteractionFlags</a> set on the label need to include either LinksAccessibleByMouse or LinksAccessibleByKeyboard.</p>
<p>The default value is false.</p>
<p>This property was introduced in Qt 4.2.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> bool </td><td class="memItemRight bottomAlign"><span class="name"><b>openExternalLinks</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setOpenExternalLinks</b></span> ( bool <i>open</i> )</td></tr>
</table>
<p><b>See also </b><a href="qlabel.html#textInteractionFlags-prop">textInteractionFlags</a>().</p>
<!-- @@@openExternalLinks -->
<!-- $$$pixmap-prop$$$pixmap$$$setPixmapconstQPixmap& -->
<h3 class="fn"><a name="pixmap-prop"></a><span class="name">pixmap</span> : <span class="type"><a href="qpixmap.html">QPixmap</a></span></h3>
<p>This property holds the label's pixmap.</p>
<p>If no pixmap has been set this will return 0.</p>
<p>Setting the pixmap clears any previous content. The buddy shortcut, if any, is disabled.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> const QPixmap * </td><td class="memItemRight bottomAlign"><span class="name"><b>pixmap</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setPixmap</b></span> ( const QPixmap & )</td></tr>
</table>
<!-- @@@pixmap -->
<!-- $$$scaledContents-prop$$$hasScaledContents$$$setScaledContentsbool -->
<h3 class="fn"><a name="scaledContents-prop"></a><span class="name">scaledContents</span> : <span class="type">bool</span></h3>
<p>This property holds whether the label will scale its contents to fill all available space.</p>
<p>When enabled and the label shows a pixmap, it will scale the pixmap to fill the available space.</p>
<p>This property's default is false.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> bool </td><td class="memItemRight bottomAlign"><span class="name"><b>hasScaledContents</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setScaledContents</b></span> ( bool )</td></tr>
</table>
<!-- @@@scaledContents -->
<!-- $$$selectedText-prop$$$selectedText -->
<h3 class="fn"><a name="selectedText-prop"></a><span class="name">selectedText</span> : const <span class="type"><a href="qstring.html">QString</a></span></h3>
<p>This property holds the selected text.</p>
<p>If there is no selected text this property's value is an empty string.</p>
<p>By default, this property contains an empty string.</p>
<p><b>Note:</b> The <a href="qlabel.html#textInteractionFlags-prop">textInteractionFlags</a> set on the label need to include either TextSelectableByMouse or TextSelectableByKeyboard.</p>
<p>This property was introduced in Qt 4.7.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QString </td><td class="memItemRight bottomAlign"><span class="name"><b>selectedText</b></span> () const</td></tr>
</table>
<p><b>See also </b><a href="qlabel.html#hasSelectedText-prop">hasSelectedText</a>().</p>
<!-- @@@selectedText -->
<!-- $$$text-prop$$$text$$$setTextconstQString& -->
<h3 class="fn"><a name="text-prop"></a><span class="name">text</span> : <span class="type"><a href="qstring.html">QString</a></span></h3>
<p>This property holds the label's text.</p>
<p>If no text has been set this will return an empty string. Setting the text clears any previous content.</p>
<p>The text will be interpreted either as plain text or as rich text, depending on the text format setting; see <a href="qlabel.html#textFormat-prop">setTextFormat</a>(). The default setting is <a href="qt.html#TextFormat-enum">Qt::AutoText</a>; i.e. <a href="qlabel.html">QLabel</a> will try to auto-detect the format of the text set.</p>
<p>If a buddy has been set, the buddy mnemonic key is updated from the new text.</p>
<p>Note that <a href="qlabel.html">QLabel</a> is well-suited to display small rich text documents, such as 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. <a href="qtextedit.html">QTextEdit</a> can also provide a scroll bar when necessary.</p>
<p><b>Note:</b> This function enables mouse tracking if <i>text</i> contains rich text.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QString </td><td class="memItemRight bottomAlign"><span class="name"><b>text</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setText</b></span> ( const QString & )</td></tr>
</table>
<p><b>See also </b><a href="qlabel.html#textFormat-prop">setTextFormat</a>(), <a href="qlabel.html#setBuddy">setBuddy</a>(), and <a href="qlabel.html#alignment-prop">alignment</a>.</p>
<!-- @@@text -->
<!-- $$$textFormat-prop$$$textFormat$$$setTextFormatQt::TextFormat -->
<h3 class="fn"><a name="textFormat-prop"></a><span class="name">textFormat</span> : <span class="type"><a href="qt.html#TextFormat-enum">Qt::TextFormat</a></span></h3>
<p>This property holds the label's text format.</p>
<p>See the <a href="qt.html#TextFormat-enum">Qt::TextFormat</a> enum for an explanation of the possible options.</p>
<p>The default format is <a href="qt.html#TextFormat-enum">Qt::AutoText</a>.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> Qt::TextFormat </td><td class="memItemRight bottomAlign"><span class="name"><b>textFormat</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setTextFormat</b></span> ( Qt::TextFormat )</td></tr>
</table>
<p><b>See also </b><a href="qlabel.html#text-prop">text</a>().</p>
<!-- @@@textFormat -->
<!-- $$$textInteractionFlags-prop$$$textInteractionFlags$$$setTextInteractionFlagsQt::TextInteractionFlags -->
<h3 class="fn"><a name="textInteractionFlags-prop"></a><span class="name">textInteractionFlags</span> : <span class="type"><a href="qt.html#TextInteractionFlag-enum">Qt::TextInteractionFlags</a></span></h3>
<p>Specifies how the label should interact with user input if it displays text.</p>
<p>If the flags contain <a href="qt.html#TextInteractionFlag-enum">Qt::LinksAccessibleByKeyboard</a> the focus policy is also automatically set to <a href="qt.html#FocusPolicy-enum">Qt::StrongFocus</a>. If <a href="qt.html#TextInteractionFlag-enum">Qt::TextSelectableByKeyboard</a> is set then the focus policy is set to <a href="qt.html#FocusPolicy-enum">Qt::ClickFocus</a>.</p>
<p>The default value is <a href="qt.html#TextInteractionFlag-enum">Qt::LinksAccessibleByMouse</a>.</p>
<p>This property was introduced in Qt 4.2.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> Qt::TextInteractionFlags </td><td class="memItemRight bottomAlign"><span class="name"><b>textInteractionFlags</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setTextInteractionFlags</b></span> ( Qt::TextInteractionFlags <i>flags</i> )</td></tr>
</table>
<!-- @@@textInteractionFlags -->
<!-- $$$wordWrap-prop$$$wordWrap$$$setWordWrapbool -->
<h3 class="fn"><a name="wordWrap-prop"></a><span class="name">wordWrap</span> : <span class="type">bool</span></h3>
<p>This property holds the label's word-wrapping policy.</p>
<p>If this property is true then label text is wrapped where necessary at word-breaks; otherwise it is not wrapped at all.</p>
<p>By default, word wrap is disabled.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> bool </td><td class="memItemRight bottomAlign"><span class="name"><b>wordWrap</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setWordWrap</b></span> ( bool <i>on</i> )</td></tr>
</table>
<p><b>See also </b><a href="qlabel.html#text-prop">text</a>.</p>
<!-- @@@wordWrap -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QLabel[overload1]$$$QLabelQWidget*Qt::WindowFlags -->
<h3 class="fn"><a name="QLabel"></a>QLabel::<span class="name">QLabel</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>parent</i> = 0, <span class="type"><a href="qt.html#WindowType-enum">Qt::WindowFlags</a></span> <i>f</i> = 0 )</h3>
<p>Constructs an empty label.</p>
<p>The <i>parent</i> and widget flag <i>f</i>, arguments are passed to the <a href="qframe.html">QFrame</a> constructor.</p>
<p><b>See also </b><a href="qlabel.html#alignment-prop">setAlignment</a>(), <a href="qframe.html#setFrameStyle">setFrameStyle</a>(), and <a href="qlabel.html#indent-prop">setIndent</a>().</p>
<!-- @@@QLabel -->
<!-- $$$QLabel$$$QLabelconstQString&QWidget*Qt::WindowFlags -->
<h3 class="fn"><a name="QLabel-2"></a>QLabel::<span class="name">QLabel</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>text</i>, <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>parent</i> = 0, <span class="type"><a href="qt.html#WindowType-enum">Qt::WindowFlags</a></span> <i>f</i> = 0 )</h3>
<p>Constructs a label that displays the text, <i>text</i>.</p>
<p>The <i>parent</i> and widget flag <i>f</i>, arguments are passed to the <a href="qframe.html">QFrame</a> constructor.</p>
<p><b>See also </b><a href="qlabel.html#text-prop">setText</a>(), <a href="qlabel.html#alignment-prop">setAlignment</a>(), <a href="qframe.html#setFrameStyle">setFrameStyle</a>(), and <a href="qlabel.html#indent-prop">setIndent</a>().</p>
<!-- @@@QLabel -->
<!-- $$$~QLabel[overload1]$$$~QLabel -->
<h3 class="fn"><a name="dtor.QLabel"></a>QLabel::<span class="name">~QLabel</span> ()</h3>
<p>Destroys the label.</p>
<!-- @@@~QLabel -->
<!-- $$$buddy[overload1]$$$buddy -->
<h3 class="fn"><a name="buddy"></a><span class="type"><a href="qwidget.html">QWidget</a></span> * QLabel::<span class="name">buddy</span> () const</h3>
<p>Returns this label's buddy, or 0 if no buddy is currently set.</p>
<p><b>See also </b><a href="qlabel.html#setBuddy">setBuddy</a>().</p>
<!-- @@@buddy -->
<!-- $$$changeEvent[overload1]$$$changeEventQEvent* -->
<h3 class="fn"><a name="changeEvent"></a><span class="type">void</span> QLabel::<span class="name">changeEvent</span> ( <span class="type"><a href="qevent.html">QEvent</a></span> * <i>ev</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#changeEvent">QWidget::changeEvent</a>().</p>
<!-- @@@changeEvent -->
<!-- $$$clear[overload1]$$$clear -->
<h3 class="fn"><a name="clear"></a><span class="type">void</span> QLabel::<span class="name">clear</span> ()<tt> [slot]</tt></h3>
<p>Clears any label contents.</p>
<!-- @@@clear -->
<!-- $$$contextMenuEvent[overload1]$$$contextMenuEventQContextMenuEvent* -->
<h3 class="fn"><a name="contextMenuEvent"></a><span class="type">void</span> QLabel::<span class="name">contextMenuEvent</span> ( <span class="type"><a href="qcontextmenuevent.html">QContextMenuEvent</a></span> * <i>ev</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#contextMenuEvent">QWidget::contextMenuEvent</a>().</p>
<!-- @@@contextMenuEvent -->
<!-- $$$event[overload1]$$$eventQEvent* -->
<h3 class="fn"><a name="event"></a><span class="type">bool</span> QLabel::<span class="name">event</span> ( <span class="type"><a href="qevent.html">QEvent</a></span> * <i>e</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qobject.html#event">QObject::event</a>().</p>
<!-- @@@event -->
<!-- $$$focusInEvent[overload1]$$$focusInEventQFocusEvent* -->
<h3 class="fn"><a name="focusInEvent"></a><span class="type">void</span> QLabel::<span class="name">focusInEvent</span> ( <span class="type"><a href="qfocusevent.html">QFocusEvent</a></span> * <i>ev</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#focusInEvent">QWidget::focusInEvent</a>().</p>
<!-- @@@focusInEvent -->
<!-- $$$focusNextPrevChild[overload1]$$$focusNextPrevChildbool -->
<h3 class="fn"><a name="focusNextPrevChild"></a><span class="type">bool</span> QLabel::<span class="name">focusNextPrevChild</span> ( <span class="type">bool</span> <i>next</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#focusNextPrevChild">QWidget::focusNextPrevChild</a>().</p>
<!-- @@@focusNextPrevChild -->
<!-- $$$focusOutEvent[overload1]$$$focusOutEventQFocusEvent* -->
<h3 class="fn"><a name="focusOutEvent"></a><span class="type">void</span> QLabel::<span class="name">focusOutEvent</span> ( <span class="type"><a href="qfocusevent.html">QFocusEvent</a></span> * <i>ev</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#focusOutEvent">QWidget::focusOutEvent</a>().</p>
<!-- @@@focusOutEvent -->
<!-- $$$heightForWidth[overload1]$$$heightForWidthint -->
<h3 class="fn"><a name="heightForWidth"></a><span class="type">int</span> QLabel::<span class="name">heightForWidth</span> ( <span class="type">int</span> <i>w</i> ) const<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#heightForWidth">QWidget::heightForWidth</a>().</p>
<!-- @@@heightForWidth -->
<!-- $$$keyPressEvent[overload1]$$$keyPressEventQKeyEvent* -->
<h3 class="fn"><a name="keyPressEvent"></a><span class="type">void</span> QLabel::<span class="name">keyPressEvent</span> ( <span class="type"><a href="qkeyevent.html">QKeyEvent</a></span> * <i>ev</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#keyPressEvent">QWidget::keyPressEvent</a>().</p>
<!-- @@@keyPressEvent -->
<!-- $$$linkActivated[overload1]$$$linkActivatedconstQString& -->
<h3 class="fn"><a name="linkActivated"></a><span class="type">void</span> QLabel::<span class="name">linkActivated</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>link</i> )<tt> [signal]</tt></h3>
<p>This signal is emitted when the user clicks a link. The URL referred to by the anchor is passed in <i>link</i>.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qlabel.html#linkHovered">linkHovered</a>().</p>
<!-- @@@linkActivated -->
<!-- $$$linkHovered[overload1]$$$linkHoveredconstQString& -->
<h3 class="fn"><a name="linkHovered"></a><span class="type">void</span> QLabel::<span class="name">linkHovered</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>link</i> )<tt> [signal]</tt></h3>
<p>This signal is emitted when the user hovers over a link. The URL referred to by the anchor is passed in <i>link</i>.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qlabel.html#linkActivated">linkActivated</a>().</p>
<!-- @@@linkHovered -->
<!-- $$$minimumSizeHint[overload1]$$$minimumSizeHint -->
<h3 class="fn"><a name="minimumSizeHint"></a><span class="type"><a href="qsize.html">QSize</a></span> QLabel::<span class="name">minimumSizeHint</span> () const<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#minimumSizeHint-prop">QWidget::minimumSizeHint</a>().</p>
<!-- @@@minimumSizeHint -->
<!-- $$$mouseMoveEvent[overload1]$$$mouseMoveEventQMouseEvent* -->
<h3 class="fn"><a name="mouseMoveEvent"></a><span class="type">void</span> QLabel::<span class="name">mouseMoveEvent</span> ( <span class="type"><a href="qmouseevent.html">QMouseEvent</a></span> * <i>ev</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#mouseMoveEvent">QWidget::mouseMoveEvent</a>().</p>
<!-- @@@mouseMoveEvent -->
<!-- $$$mousePressEvent[overload1]$$$mousePressEventQMouseEvent* -->
<h3 class="fn"><a name="mousePressEvent"></a><span class="type">void</span> QLabel::<span class="name">mousePressEvent</span> ( <span class="type"><a href="qmouseevent.html">QMouseEvent</a></span> * <i>ev</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#mousePressEvent">QWidget::mousePressEvent</a>().</p>
<!-- @@@mousePressEvent -->
<!-- $$$mouseReleaseEvent[overload1]$$$mouseReleaseEventQMouseEvent* -->
<h3 class="fn"><a name="mouseReleaseEvent"></a><span class="type">void</span> QLabel::<span class="name">mouseReleaseEvent</span> ( <span class="type"><a href="qmouseevent.html">QMouseEvent</a></span> * <i>ev</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#mouseReleaseEvent">QWidget::mouseReleaseEvent</a>().</p>
<!-- @@@mouseReleaseEvent -->
<!-- $$$movie[overload1]$$$movie -->
<h3 class="fn"><a name="movie"></a><span class="type"><a href="qmovie.html">QMovie</a></span> * QLabel::<span class="name">movie</span> () const</h3>
<p>Returns a pointer to the label's movie, or 0 if no movie has been set.</p>
<p><b>See also </b><a href="qlabel.html#setMovie">setMovie</a>().</p>
<!-- @@@movie -->
<!-- $$$paintEvent[overload1]$$$paintEventQPaintEvent* -->
<h3 class="fn"><a name="paintEvent"></a><span class="type">void</span> QLabel::<span class="name">paintEvent</span> ( <span class="type"><a href="qpaintevent.html">QPaintEvent</a></span> * )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#paintEvent">QWidget::paintEvent</a>().</p>
<!-- @@@paintEvent -->
<!-- $$$picture[overload1]$$$picture -->
<h3 class="fn"><a name="picture"></a>const <span class="type"><a href="qpicture.html">QPicture</a></span> * QLabel::<span class="name">picture</span> () const</h3>
<p>Returns the label's picture or 0 if the label doesn't have a picture.</p>
<p><b>See also </b><a href="qlabel.html#setPicture">setPicture</a>().</p>
<!-- @@@picture -->
<!-- $$$selectionStart[overload1]$$$selectionStart -->
<h3 class="fn"><a name="selectionStart"></a><span class="type">int</span> QLabel::<span class="name">selectionStart</span> () const</h3>
<p>selectionStart() returns the index of the first selected character in the label or -1 if no text is selected.</p>
<p><b>Note:</b> The <a href="qlabel.html#textInteractionFlags-prop">textInteractionFlags</a> set on the label need to include either TextSelectableByMouse or TextSelectableByKeyboard.</p>
<p>This function was introduced in Qt 4.7.</p>
<p><b>See also </b><a href="qlabel.html#selectedText-prop">selectedText</a>().</p>
<!-- @@@selectionStart -->
<!-- $$$setBuddy[overload1]$$$setBuddyQWidget* -->
<h3 class="fn"><a name="setBuddy"></a><span class="type">void</span> QLabel::<span class="name">setBuddy</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>buddy</i> )</h3>
<p>Sets this label's buddy to <i>buddy</i>.</p>
<p>When the user presses the shortcut key indicated by this label, the keyboard focus is transferred to the label's buddy widget.</p>
<p>The buddy mechanism is only available for QLabels that contain text in which one character is prefixed with an ampersand, '&'. This character is set as the shortcut key. See the <a href="qkeysequence.html#mnemonic">QKeySequence::mnemonic</a>() documentation for details (to display an actual ampersand, use '&&').</p>
<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:</p>
<pre class="cpp"> <span class="type"><a href="qlineedit.html">QLineEdit</a></span> <span class="operator">*</span>nameEd <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlineedit.html">QLineEdit</a></span>(<span class="keyword">this</span>);
<span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>nameLb <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(<span class="string">"&Name:"</span><span class="operator">,</span> <span class="keyword">this</span>);
nameLb<span class="operator">-</span><span class="operator">></span>setBuddy(nameEd);
<span class="type"><a href="qlineedit.html">QLineEdit</a></span> <span class="operator">*</span>phoneEd <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlineedit.html">QLineEdit</a></span>(<span class="keyword">this</span>);
<span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>phoneLb <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(<span class="string">"&Phone:"</span><span class="operator">,</span> <span class="keyword">this</span>);
phoneLb<span class="operator">-</span><span class="operator">></span>setBuddy(phoneEd);
<span class="comment">// (layout setup not shown)</span></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>
<p>To unset a previously set buddy, call this function with <i>buddy</i> set to 0.</p>
<p><b>See also </b><a href="qlabel.html#buddy">buddy</a>(), <a href="qlabel.html#text-prop">setText</a>(), <a href="qshortcut.html">QShortcut</a>, and <a href="qlabel.html#alignment-prop">setAlignment</a>().</p>
<!-- @@@setBuddy -->
<!-- $$$setMovie[overload1]$$$setMovieQMovie* -->
<h3 class="fn"><a name="setMovie"></a><span class="type">void</span> QLabel::<span class="name">setMovie</span> ( <span class="type"><a href="qmovie.html">QMovie</a></span> * <i>movie</i> )<tt> [slot]</tt></h3>
<p>Sets the label contents to <i>movie</i>. Any previous content is cleared. The label does NOT take ownership of the movie.</p>
<p>The buddy shortcut, if any, is disabled.</p>
<p><b>See also </b><a href="qlabel.html#movie">movie</a>() and <a href="qlabel.html#setBuddy">setBuddy</a>().</p>
<!-- @@@setMovie -->
<!-- $$$setNum[overload1]$$$setNumint -->
<h3 class="fn"><a name="setNum"></a><span class="type">void</span> QLabel::<span class="name">setNum</span> ( <span class="type">int</span> <i>num</i> )<tt> [slot]</tt></h3>
<p>Sets the label contents to plain text containing the textual representation of integer <i>num</i>. Any previous content is cleared. Does nothing if the integer's string representation is the same as the current contents of the label.</p>
<p>The buddy shortcut, if any, is disabled.</p>
<p><b>See also </b><a href="qlabel.html#text-prop">setText</a>(), <a href="qstring.html#setNum">QString::setNum</a>(), and <a href="qlabel.html#setBuddy">setBuddy</a>().</p>
<!-- @@@setNum -->
<!-- $$$setNum$$$setNumdouble -->
<h3 class="fn"><a name="setNum-2"></a><span class="type">void</span> QLabel::<span class="name">setNum</span> ( <span class="type">double</span> <i>num</i> )<tt> [slot]</tt></h3>
<p>This is an overloaded function.</p>
<p>Sets the label contents to plain text containing the textual representation of double <i>num</i>. Any previous content is cleared. Does nothing if the double's string representation is the same as the current contents of the label.</p>
<p>The buddy shortcut, if any, is disabled.</p>
<p><b>See also </b><a href="qlabel.html#text-prop">setText</a>(), <a href="qstring.html#setNum">QString::setNum</a>(), and <a href="qlabel.html#setBuddy">setBuddy</a>().</p>
<!-- @@@setNum -->
<!-- $$$setPicture[overload1]$$$setPictureconstQPicture& -->
<h3 class="fn"><a name="setPicture"></a><span class="type">void</span> QLabel::<span class="name">setPicture</span> ( const <span class="type"><a href="qpicture.html">QPicture</a></span> & <i>picture</i> )<tt> [slot]</tt></h3>
<p>Sets the label contents to <i>picture</i>. Any previous content is cleared.</p>
<p>The buddy shortcut, if any, is disabled.</p>
<p><b>See also </b><a href="qlabel.html#picture">picture</a>() and <a href="qlabel.html#setBuddy">setBuddy</a>().</p>
<!-- @@@setPicture -->
<!-- $$$setSelection[overload1]$$$setSelectionintint -->
<h3 class="fn"><a name="setSelection"></a><span class="type">void</span> QLabel::<span class="name">setSelection</span> ( <span class="type">int</span> <i>start</i>, <span class="type">int</span> <i>length</i> )</h3>
<p>Selects text from position <i>start</i> and for <i>length</i> characters.</p>
<p><b>Note:</b> The <a href="qlabel.html#textInteractionFlags-prop">textInteractionFlags</a> set on the label need to include either TextSelectableByMouse or TextSelectableByKeyboard.</p>
<p>This function was introduced in Qt 4.7.</p>
<p><b>See also </b><a href="qlabel.html#selectedText-prop">selectedText</a>().</p>
<!-- @@@setSelection -->
<!-- $$$sizeHint[overload1]$$$sizeHint -->
<h3 class="fn"><a name="sizeHint"></a><span class="type"><a href="qsize.html">QSize</a></span> QLabel::<span class="name">sizeHint</span> () const<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#sizeHint-prop">QWidget::sizeHint</a>().</p>
<!-- @@@sizeHint -->
</div>
<div class="ft">
<span></span>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2012 Nokia Corporation and/or its
subsidiaries. Documentation contributions included herein are the copyrights of
their respective owners.</p>
<br />
<p>
The documentation provided herein is licensed under the terms of the
<a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
License version 1.3</a> as published by the Free Software Foundation.</p>
<p>
Documentation sources may be obtained from <a href="http://www.qt-project.org">
www.qt-project.org</a>.</p>
<br />
<p>
Nokia, Qt and their respective logos are trademarks of Nokia Corporation
in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. <a title="Privacy Policy"
href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>
|