source: trunk/doc/html/qwhatsthis.html

Last change on this file was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 14.5 KB
Line 
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/qwhatsthis.cpp:61 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QWhatsThis Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { 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&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;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&nbsp;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>QWhatsThis Class Reference</h1>
33
34<p>The QWhatsThis class provides a simple description of any
35widget, i.e. answering the question "What's this?".
36<a href="#details">More...</a>
37<p><tt>#include &lt;<a href="qwhatsthis-h.html">qwhatsthis.h</a>&gt;</tt>
38<p>Inherits <a href="qt.html">Qt</a>.
39<p><a href="qwhatsthis-members.html">List of all member functions.</a>
40<h2>Public Members</h2>
41<ul>
42<li class=fn><a href="#QWhatsThis"><b>QWhatsThis</b></a> ( QWidget&nbsp;*&nbsp;widget )</li>
43<li class=fn>virtual <a href="#~QWhatsThis"><b>~QWhatsThis</b></a> ()</li>
44<li class=fn>virtual QString <a href="#text"><b>text</b></a> ( const QPoint &amp; )</li>
45<li class=fn>virtual bool <a href="#clicked"><b>clicked</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;href )</li>
46</ul>
47<h2>Static Public Members</h2>
48<ul>
49<li class=fn>void <a href="#setFont"><b>setFont</b></a> ( const&nbsp;QFont&nbsp;&amp;&nbsp;font )</li>
50<li class=fn>void <a href="#add"><b>add</b></a> ( QWidget&nbsp;*&nbsp;widget, const&nbsp;QString&nbsp;&amp;&nbsp;text )</li>
51<li class=fn>void <a href="#remove"><b>remove</b></a> ( QWidget&nbsp;*&nbsp;widget )</li>
52<li class=fn>QString <a href="#textFor"><b>textFor</b></a> ( QWidget&nbsp;*&nbsp;w, const&nbsp;QPoint&nbsp;&amp;&nbsp;pos = QPoint ( ), bool&nbsp;includeParents = FALSE )</li>
53<li class=fn>QToolButton * <a href="#whatsThisButton"><b>whatsThisButton</b></a> ( QWidget&nbsp;*&nbsp;parent )</li>
54<li class=fn>void <a href="#enterWhatsThisMode"><b>enterWhatsThisMode</b></a> ()</li>
55<li class=fn>bool <a href="#inWhatsThisMode"><b>inWhatsThisMode</b></a> ()</li>
56<li class=fn>void <a href="#leaveWhatsThisMode"><b>leaveWhatsThisMode</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;text = QString::null, const&nbsp;QPoint&nbsp;&amp;&nbsp;pos = QCursor::pos ( ), QWidget&nbsp;*&nbsp;w = 0 )</li>
57<li class=fn>void <a href="#display"><b>display</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;text, const&nbsp;QPoint&nbsp;&amp;&nbsp;pos = QCursor::pos ( ), QWidget&nbsp;*&nbsp;w = 0 )</li>
58</ul>
59<hr><a name="details"></a><h2>Detailed Description</h2>
60
61
62The QWhatsThis class provides a simple description of any
63widget, i.e. answering the question "What's this?".
64<p>
65
66<p> "What's this?" help is part of an application's online <a href="helpsystem.html#help-system">help system</a>
67that provides users with information about functionality, usage,
68background etc., in various levels of detail from short tool tips
69to full text browsing help windows.
70<p> QWhatsThis provides a single window with an explanatory text that
71pops up when the user asks "What's this?". The default way to do
72this is to focus the relevant widget and press Shift+F1. The help
73text appears immediately; it goes away as soon as the user does
74something else.
75<p> (Note that if there is an accelerator for Shift+F1, this mechanism
76will not work.)
77<p> To add "What's this?" text to a widget you simply call
78<a href="#add">QWhatsThis::add</a>() for the widget. For example, to assign text to a
79menu item, call <a href="qmenudata.html#setWhatsThis">QMenuData::setWhatsThis</a>(); for a global
80accelerator key, call <a href="qaccel.html#setWhatsThis">QAccel::setWhatsThis</a>() and If you're using
81actions, use <a href="qaction.html#setWhatsThis">QAction::setWhatsThis</a>().
82<p> The text can be either rich text or plain text. If you specify a
83rich text formatted string, it will be rendered using the default
84stylesheet. This makes it possible to embed images. See
85<a href="qstylesheet.html#defaultSheet">QStyleSheet::defaultSheet</a>() for details.
86<p>
87
88<pre> const char * fileOpenText = "&lt;p&gt;&lt;img source=\"fileopen\"&gt; "
89 "Click this button to open a &lt;em&gt;new file&lt;/em&gt;. &lt;br&gt;"
90 "You can also select the &lt;b&gt;Open&lt;/b&gt; command "
91 "from the &lt;b&gt;File&lt;/b&gt; menu.&lt;/p&gt;";
92 <a name="x2104"></a> QMimeSourceFactory::<a href="qmimesourcefactory.html#defaultFactory">defaultFactory</a>()-&gt;setPixmap( "fileopen",
93 <a name="x2102"></a> fileOpenAction-&gt;<a href="qaction.html#iconSet">iconSet</a>().pixmap() );
94 <a name="x2103"></a> fileOpenAction-&gt;<a href="qaction.html#setWhatsThis">setWhatsThis</a>( fileOpenText );
95</pre>
96<p> An alternative way to enter "What's this?" mode is to use the
97ready-made tool bar tool button from
98<a href="#whatsThisButton">QWhatsThis::whatsThisButton</a>(). By invoking this context help
99button (in the picture below the first one from the right) the
100user switches into "What's this?" mode. If they now click on a
101widget the appropriate help text is shown. The mode is left when
102help is given or when the user presses Esc.
103<p> <center><img src="whatsthis.png"></center>
104<p> If you are using <a href="qmainwindow.html">QMainWindow</a> you can also use the
105<a href="qmainwindow.html#whatsThis">QMainWindow::whatsThis</a>() slot to invoke the mode from a menu item.
106<p> For more control you can create a dedicated QWhatsThis object for
107a special widget. By subclassing and reimplementing
108<a href="#text">QWhatsThis::text</a>() it is possible to have different help texts,
109depending on the position of the mouse click. By reimplementing
110<a href="#clicked">QWhatsThis::clicked</a>() it is possible to have hyperlinks inside the
111help texts.
112<p> If you wish to control the "What's this?" behavior of a widget
113manually see <a href="qwidget.html#customWhatsThis">QWidget::customWhatsThis</a>().
114<p> The What's This object can be removed using <a href="#remove">QWhatsThis::remove</a>(),
115although this is rarely necessary because it is automatically
116removed when the widget is destroyed.
117<p> <p>See also <a href="qtooltip.html">QToolTip</a> and <a href="helpsystem.html">Help System</a>.
118
119<hr><h2>Member Function Documentation</h2>
120<h3 class=fn><a name="QWhatsThis"></a>QWhatsThis::QWhatsThis ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;widget )
121</h3>
122Constructs a dynamic "What's this?" object for <em>widget</em>. The
123object is deleted when the <em>widget</em> is destroyed.
124<p> When the widget is queried by the user the <a href="#text">text</a>() function of this
125QWhatsThis will be called to provide the appropriate text, rather
126than using the text assigned by <a href="#add">add</a>().
127
128<h3 class=fn><a name="~QWhatsThis"></a>QWhatsThis::~QWhatsThis ()<tt> [virtual]</tt>
129</h3>
130Destroys the object and frees any allocated resources.
131
132<h3 class=fn>void <a name="add"></a>QWhatsThis::add ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;widget, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text )<tt> [static]</tt>
133</h3>
134Adds <em>text</em> as "What's this" help for <em>widget</em>. If the text is
135rich text formatted (i.e. it contains markup) it will be rendered
136with the default stylesheet <a href="qstylesheet.html#defaultSheet">QStyleSheet::defaultSheet</a>().
137<p> The text is destroyed if the widget is later destroyed, so it need
138not be explicitly removed.
139<p> <p>See also <a href="#remove">remove</a>().
140
141<p>Examples: <a href="simple-application-example.html#x1591">application/application.cpp</a>, <a href="helpsystem-example.html#x2698">helpsystem/mainwindow.cpp</a>, and <a href="mdi-example.html#x2075">mdi/application.cpp</a>.
142<h3 class=fn>bool <a name="clicked"></a>QWhatsThis::clicked ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;href )<tt> [virtual]</tt>
143</h3>
144
145<p> This virtual function is called when the user clicks inside the
146"What's this?" window. <em>href</em> is the link the user clicked on, or
147<a href="qstring.html#QString-null">QString::null</a> if there was no link.
148<p> If the function returns TRUE (the default), the "What's this?"
149window is closed, otherwise it remains visible.
150<p> The default implementation ignores <em>href</em> and returns TRUE.
151
152<h3 class=fn>void <a name="display"></a>QWhatsThis::display ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;pos = QCursor::pos ( ), <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;w = 0 )<tt> [static]</tt>
153</h3>
154Display <em>text</em> in a help window at the global screen position <em>pos</em>.
155<p> If widget <em>w</em> is not 0 and has its own dedicated QWhatsThis
156object, this object will receive <a href="#clicked">clicked</a>() messages when the user
157clicks on hyperlinks inside the help text.
158<p> <p>See also <a href="#clicked">QWhatsThis::clicked</a>().
159
160<h3 class=fn>void <a name="enterWhatsThisMode"></a>QWhatsThis::enterWhatsThisMode ()<tt> [static]</tt>
161</h3>
162Enters "What's this?" mode and returns immediately.
163<p> Qt will install a special cursor and take over mouse input until
164the user clicks somewhere. It then shows any help available and
165ends "What's this?" mode. Finally, Qt removes the special cursor
166and help window and then restores ordinary event processing, at
167which point the left mouse button is no longer pressed.
168<p> The user can also use the Esc key to leave "What's this?" mode.
169<p> <p>See also <a href="#inWhatsThisMode">inWhatsThisMode</a>() and <a href="#leaveWhatsThisMode">leaveWhatsThisMode</a>().
170
171<h3 class=fn>bool <a name="inWhatsThisMode"></a>QWhatsThis::inWhatsThisMode ()<tt> [static]</tt>
172</h3>
173Returns TRUE if the application is in "What's this?" mode;
174otherwise returns FALSE.
175<p> <p>See also <a href="#enterWhatsThisMode">enterWhatsThisMode</a>() and <a href="#leaveWhatsThisMode">leaveWhatsThisMode</a>().
176
177<h3 class=fn>void <a name="leaveWhatsThisMode"></a>QWhatsThis::leaveWhatsThisMode ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text = QString::null, const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;pos = QCursor::pos ( ), <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;w = 0 )<tt> [static]</tt>
178</h3>
179Leaves "What's this?" question mode.
180<p> This function is used internally by widgets that support
181<a href="qwidget.html#customWhatsThis">QWidget::customWhatsThis</a>(); applications do not usually call it.
182An example of such a widget is QPopupMenu: menus still work
183normally in "What's this?" mode but also provide help texts for
184individual menu items.
185<p> If <em>text</em> is not <a href="qstring.html#QString-null">QString::null</a>, a "What's this?" help window is
186displayed at the global screen position <em>pos</em>. If widget <em>w</em> is
187not 0 and has its own dedicated QWhatsThis object, this object
188will receive <a href="#clicked">clicked</a>() messages when the user clicks on hyperlinks
189inside the help text.
190<p> <p>See also <a href="#inWhatsThisMode">inWhatsThisMode</a>(), <a href="#enterWhatsThisMode">enterWhatsThisMode</a>(), and <a href="#clicked">QWhatsThis::clicked</a>().
191
192<h3 class=fn>void <a name="remove"></a>QWhatsThis::remove ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;widget )<tt> [static]</tt>
193</h3>
194Removes the "What's this?" help associated with the <em>widget</em>.
195This happens automatically if the widget is destroyed.
196<p> <p>See also <a href="#add">add</a>().
197
198<h3 class=fn>void <a name="setFont"></a>QWhatsThis::setFont ( const&nbsp;<a href="qfont.html">QFont</a>&nbsp;&amp;&nbsp;font )<tt> [static]</tt>
199</h3>
200Sets the font for all "What's this?" helps to <em>font</em>.
201
202<h3 class=fn><a href="qstring.html">QString</a> <a name="text"></a>QWhatsThis::text ( const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp; )<tt> [virtual]</tt>
203</h3>
204This virtual function returns the text for position <em>p</em> in the
205widget that this "What's this?" object documents. If there is no
206"What's this?" text for the position, <a href="qstring.html#QString-null">QString::null</a> is returned.
207<p> The default implementation returns QString::null.
208
209<h3 class=fn><a href="qstring.html">QString</a> <a name="textFor"></a>QWhatsThis::textFor ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;w, const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;pos = QPoint ( ), bool&nbsp;includeParents = FALSE )<tt> [static]</tt>
210</h3>
211Returns the what's this text for widget <em>w</em> or <a href="qstring.html#QString-null">QString::null</a> if
212there is no "What's this?" help for the widget. <em>pos</em> contains
213the mouse position; this is useful, for example, if you've
214subclassed to make the text that is displayed position dependent.
215<p> If <em>includeParents</em> is TRUE, parent widgets are taken into
216consideration as well when looking for what's this help text.
217<p> <p>See also <a href="#add">add</a>().
218
219<h3 class=fn><a href="qtoolbutton.html">QToolButton</a>&nbsp;* <a name="whatsThisButton"></a>QWhatsThis::whatsThisButton ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent )<tt> [static]</tt>
220</h3>
221Creates a <a href="qtoolbutton.html">QToolButton</a> preconfigured to enter "What's this?" mode
222when clicked. You will often use this with a tool bar as <em>parent</em>:
223<pre>
224 (void) QWhatsThis::whatsThisButton( my_help_tool_bar );
225 </pre>
226
227
228<p>Example: <a href="helpsystem-example.html#x2699">helpsystem/mainwindow.cpp</a>.
229<!-- eof -->
230<hr><p>
231This file is part of the <a href="index.html">Qt toolkit</a>.
232Copyright &copy; 1995-2007
233<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
234<table width=100% cellspacing=0 border=0><tr>
235<td>Copyright &copy; 2007
236<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
237<td align=right><div align=right>Qt 3.3.8</div>
238</table></div></address></body>
239</html>
Note: See TracBrowser for help on using the repository browser.