<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!-- qtooltip.cpp --> <head> <title>Qt 4.6: QToolTip Class Reference</title> <link href="classic.css" rel="stylesheet" type="text/css" /> </head> <body> <a name="//apple_ref/cpp/cl//QToolTip"></a> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td> <td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="functions.html"><font color="#004faf">All Functions</font></a> · <a href="overviews.html"><font color="#004faf">Overviews</font></a></td></tr></table><h1 class="title">QToolTip Class Reference<br /><span class="small-subtitle">[<a href="qtgui.html">QtGui</a> module]</span> </h1> <p>The QToolTip class provides tool tips (balloon help) for any widget. <a href="#details">More...</a></p> <pre> #include <QToolTip></pre><ul> <li><a href="qtooltip-members.html">List of all members, including inherited members</a></li> <li><a href="qtooltip-qt3.html">Qt 3 support members</a></li> </ul> <hr /> <a name="static-public-members"></a> <h2>Static Public Members</h2> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top">QFont </td><td class="memItemRight" valign="bottom"><b><a href="qtooltip.html#font">font</a></b> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qtooltip.html#hideText">hideText</a></b> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qtooltip.html#isVisible">isVisible</a></b> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QPalette </td><td class="memItemRight" valign="bottom"><b><a href="qtooltip.html#palette">palette</a></b> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qtooltip.html#setFont">setFont</a></b> ( const QFont & <i>font</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qtooltip.html#setPalette">setPalette</a></b> ( const QPalette & <i>palette</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qtooltip.html#showText">showText</a></b> ( const QPoint & <i>pos</i>, const QString & <i>text</i>, QWidget * <i>w</i>, const QRect & <i>rect</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qtooltip.html#showText-2">showText</a></b> ( const QPoint & <i>pos</i>, const QString & <i>text</i>, QWidget * <i>w</i> = 0 )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><b><a href="qtooltip.html#text">text</a></b> ()</td></tr> </table> <a name="details"></a> <hr /> <h2>Detailed Description</h2> <p>The QToolTip class provides tool tips (balloon help) for any widget.</p> <p>The tip is a short piece of text reminding the user of the widget's function. It is drawn immediately below the given position in a distinctive black-on-yellow color combination. The tip can be any <a href="qtextedit.html">rich text</a> formatted string.</p> <p>Rich text displayed in a tool tip is implicitly word-wrapped unless specified differently with <tt><p style='white-space:pre'></tt>.</p> <p>The simplest and most common way to set a widget's tool tip is by calling its <a href="qwidget.html#toolTip-prop">QWidget::setToolTip</a>() function.</p> <p>It is also possible to show different tool tips for different regions of a widget, by using a <a href="qhelpevent.html">QHelpEvent</a> of type <a href="qevent.html#Type-enum">QEvent::ToolTip</a>. Intercept the help event in your widget's <a href="qwidget.html#event">event()</a> function and call <a href="qtooltip.html#showText">QToolTip::showText</a>() with the text you want to display. The <a href="widgets-tooltips.html">Tooltips</a> example illustrates this technique.</p> <p>If you are calling <a href="qtooltip.html#hideText">QToolTip::hideText</a>(), or <a href="qtooltip.html#showText">QToolTip::showText</a>() with an empty string, as a result of a <a href="qevent.html#Type-enum">ToolTip</a>-event you should also call <a href="qevent.html#ignore">ignore()</a> on the event, to signal that you don't want to start any tooltip specific modes.</p> <p>Note that, if you want to show tooltips in an item view, the model/view architecture provides functionality to set an item's tool tip; e.g., the <a href="qtablewidgetitem.html#setToolTip">QTableWidgetItem::setToolTip</a>() function. However, if you want to provide custom tool tips in an item view, you must intercept the help event in the <a href="qabstractitemview.html#viewportEvent">QAbstractItemView::viewportEvent</a>() function and handle it yourself.</p> <p>The default tool tip color and font can be customized with <a href="qtooltip.html#setPalette">setPalette</a>() and <a href="qtooltip.html#setFont">setFont</a>(). When a tooltip is currently on display, <a href="qtooltip.html#isVisible">isVisible</a>() returns true and <a href="qtooltip.html#text">text</a>() the currently visible text.</p> <p><b>Note:</b> Tool tips use the inactive color group of <a href="qpalette.html">QPalette</a>, because tool tips are not active windows.</p> <p>See also <a href="qwidget.html#toolTip-prop">QWidget::toolTip</a>, <a href="qaction.html#toolTip-prop">QAction::toolTip</a>, and <a href="widgets-tooltips.html">Tool Tips Example</a>.</p> <hr /> <h2>Member Function Documentation</h2> <a name="//apple_ref/cpp/clm/QToolTip/font"></a> <h3 class="fn"><a name="font"></a><a href="qfont.html">QFont</a> QToolTip::font () <tt> [static]</tt></h3> <p>Returns the font used to render tooltips.</p> <p>This function was introduced in Qt 4.2.</p> <p>See also <a href="qtooltip.html#setFont">setFont</a>().</p> <a name="//apple_ref/cpp/clm/QToolTip/hideText"></a> <h3 class="fn"><a name="hideText"></a>void QToolTip::hideText () <tt> [static]</tt></h3> <p>Hides the tool tip. This is the same as calling <a href="qtooltip.html#showText">showText</a>() with an empty string.</p> <p>This function was introduced in Qt 4.2.</p> <p>See also <a href="qtooltip.html#showText">showText</a>().</p> <a name="//apple_ref/cpp/clm/QToolTip/isVisible"></a> <h3 class="fn"><a name="isVisible"></a>bool QToolTip::isVisible () <tt> [static]</tt></h3> <p>Returns true if this tooltip is currently shown.</p> <p>This function was introduced in Qt 4.4.</p> <p>See also <a href="qtooltip.html#showText">showText</a>().</p> <a name="//apple_ref/cpp/clm/QToolTip/palette"></a> <h3 class="fn"><a name="palette"></a><a href="qpalette.html">QPalette</a> QToolTip::palette () <tt> [static]</tt></h3> <p>Returns the palette used to render tooltips.</p> <p><b>Note:</b> Tool tips use the inactive color group of <a href="qpalette.html">QPalette</a>, because tool tips are not active windows.</p> <p>See also <a href="qtooltip.html#setPalette">setPalette</a>().</p> <a name="//apple_ref/cpp/clm/QToolTip/setFont"></a> <h3 class="fn"><a name="setFont"></a>void QToolTip::setFont ( const <a href="qfont.html">QFont</a> & <i>font</i> ) <tt> [static]</tt></h3> <p>Sets the <i>font</i> used to render tooltips.</p> <p>This function was introduced in Qt 4.2.</p> <p>See also <a href="qtooltip.html#font">font</a>().</p> <a name="//apple_ref/cpp/clm/QToolTip/setPalette"></a> <h3 class="fn"><a name="setPalette"></a>void QToolTip::setPalette ( const <a href="qpalette.html">QPalette</a> & <i>palette</i> ) <tt> [static]</tt></h3> <p>Sets the <i>palette</i> used to render tooltips.</p> <p><b>Note:</b> Tool tips use the inactive color group of <a href="qpalette.html">QPalette</a>, because tool tips are not active windows.</p> <p>This function was introduced in Qt 4.2.</p> <p>See also <a href="qtooltip.html#palette">palette</a>().</p> <a name="//apple_ref/cpp/clm/QToolTip/showText"></a> <h3 class="fn"><a name="showText"></a>void QToolTip::showText ( const <a href="qpoint.html">QPoint</a> & <i>pos</i>, const <a href="qstring.html">QString</a> & <i>text</i>, <a href="qwidget.html">QWidget</a> * <i>w</i>, const <a href="qrect.html">QRect</a> & <i>rect</i> ) <tt> [static]</tt></h3> <p>Shows <i>text</i> as a tool tip, with the global position <i>pos</i> as the point of interest. The tool tip will be shown with a platform specific offset from this point of interest.</p> <p>If you specify a non-empty rect the tip will be hidden as soon as you move your cursor out of this area.</p> <p>The <i>rect</i> is in the coordinates of the widget you specify with <i>w</i>. If the <i>rect</i> is not empty you must specify a widget. Otherwise this argument can be 0 but it is used to determine the appropriate screen on multi-head systems.</p> <p>If <i>text</i> is empty the tool tip is hidden. If the text is the same as the currently shown tooltip, the tip will <i>not</i> move. You can force moving by first hiding the tip with an empty text, and then showing the new tip at the new position.</p> <h3 class="fn"><a name="showText-2"></a>void QToolTip::showText ( const <a href="qpoint.html">QPoint</a> & <i>pos</i>, const <a href="qstring.html">QString</a> & <i>text</i>, <a href="qwidget.html">QWidget</a> * <i>w</i> = 0 ) <tt> [static]</tt></h3> <p>This is an overloaded function.</p> <p>This is analogous to calling QToolTip::showText(<i>pos</i>, <i>text</i>, <i>w</i>, QRect())</p> <a name="//apple_ref/cpp/clm/QToolTip/text"></a> <h3 class="fn"><a name="text"></a><a href="qstring.html">QString</a> QToolTip::text () <tt> [static]</tt></h3> <p>Returns the tooltip text, if a tooltip is visible, or an empty string if a tooltip is not visible.</p> <p>This function was introduced in Qt 4.4.</p> <p /><address><hr /><div align="center"> <table width="100%" cellspacing="0" border="0"><tr class="address"> <td width="40%" align="left">Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)</td> <td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td> <td width="40%" align="right"><div align="right">Qt 4.6.3</div></td> </tr></table></div></address></body> </html>